apache/hadoop · error · DSQuotaExceededException

The DiskSpace quota is exceeded: quota = {} B = {} but disks

Error message

The DiskSpace quota is exceeded: quota = {} B = {} but diskspace consumed = {} B = {}

What it means

RouterQuotaUsage.verifyStoragespaceQuota is the diskspace twin of the namespace check: before applying a storage-space quota through the router, it compares the requested spaceQuota with the currently consumed space (getSpaceConsumed) using Quota.isViolated, and throws DSQuotaExceededException (quota and consumed bytes formatted in the message) if existing content already exceeds the new limit.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java:113

   */
  public void verifyNamespaceQuota() throws NSQuotaExceededException {
    long quota = getQuota();
    long fileAndDirectoryCount = getFileAndDirectoryCount();
    if (Quota.isViolated(quota, fileAndDirectoryCount)) {
      throw new NSQuotaExceededException(quota, fileAndDirectoryCount);
    }
  }

  /**
   * Verify if storage space quota is violated once quota is set. Relevant
   * method {@link DirectoryWithQuotaFeature#verifyStoragespaceQuota}.
   * @throws DSQuotaExceededException If the quota is exceeded.
   */
  public void verifyStoragespaceQuota() throws DSQuotaExceededException {
    long spaceQuota = getSpaceQuota();
    long spaceConsumed = getSpaceConsumed();
    if (Quota.isViolated(spaceQuota, spaceConsumed)) {
      throw new DSQuotaExceededException(spaceQuota, spaceConsumed);
    }
  }

  /**
   * Verify space quota by storage type is violated once quota is set. Relevant
   * method {@link DirectoryWithQuotaFeature#verifyQuotaByStorageType}.
   * @throws DSQuotaExceededException If the quota is exceeded.
   */
  public void verifyQuotaByStorageType() throws DSQuotaExceededException {
    for (StorageType t: StorageType.getTypesSupportingQuota()) {
      long typeQuota = getTypeQuota(t);
      if (typeQuota == HdfsConstants.QUOTA_RESET) {
        continue;
      }
      long typeConsumed = getTypeConsumed(t);
      if (Quota.isViolated(typeQuota, typeConsumed)) {
        throw new DSQuotaExceededException(typeQuota, typeConsumed);
      }

View on GitHub (pinned to 2add963021)

Solutions

  1. Set the space quota to at least the consumed bytes reported in the message (diskspace consumed=... B), then retry
  2. Or free space under the path and wait for the quota cache update cycle before applying the smaller quota
  3. Remember consumed space counts replication: estimate with file sizes x replication factor before choosing a limit

Example fix

# before
hdfs dfs -fs hdfs://router -setSpaceQuota 100G /mount/data   # consumed = 250G -> DSQuotaExceededException
# after
hdfs dfs -fs hdfs://router -setSpaceQuota 300G /mount/data  # or delete ~150G+ of data first
Defensive patterns

Strategy: validation

Validate before calling

// Check consumed bytes (with replication) before setting a space quota
ContentSummary cs = fs.getContentSummary(path);
long consumed = cs.getSpaceConsumed();
if (spaceQuota >= 0 && spaceQuota < consumed) {
  throw new IllegalArgumentException("Cannot set space quota " + spaceQuota
      + " below consumed " + consumed + " for " + path);
}

Type guard

boolean wouldViolateSpaceQuota(long spaceQuota, long spaceConsumed) {
  return spaceQuota >= 0 && spaceQuota < spaceConsumed; // mirrors Quota.isViolated
}

Try / catch

try {
  dfs.setQuota(path, HdfsConstants.QUOTA_DONT_SET, spaceQuota);
} catch (DSQuotaExceededException dsq) {
  // message carries quota=... and diskspace consumed=... in bytes: adjust and retry
  LOG.warn("Space quota rejected: {}", dsq.getMessage());
  throw dsq;
}

Prevention

When it happens

Trigger: hdfs dfs -setSpaceQuota <bytes> <path> (or the setQuota RPC) through the router where the requested byte limit is below the space already consumed under the mount point.

Common situations: Lowering space quotas during cleanup after data growth; underestimating consumed bytes (forgetting replication factor multiplies file sizes); quota decisions based on stale router quota-cache numbers after a burst of writes.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/8357bc2935826f14. Report an issue: GitHub.