{"record":{"id":"8357bc2935826f14","repo":"apache/hadoop","slug":"the-diskspace-quota-is-exceeded-quota-b","errorCode":null,"errorMessage":"The DiskSpace quota is exceeded: quota = {} B = {} but diskspace consumed = {} B = {}","messagePattern":"The DiskSpace quota is exceeded: quota = (.+?) B = (.+?) but diskspace consumed = (.+?) B = (.+?)","errorType":"exception","errorClass":"DSQuotaExceededException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java","lineNumber":113,"sourceCode":"   */\n  public void verifyNamespaceQuota() throws NSQuotaExceededException {\n    long quota = getQuota();\n    long fileAndDirectoryCount = getFileAndDirectoryCount();\n    if (Quota.isViolated(quota, fileAndDirectoryCount)) {\n      throw new NSQuotaExceededException(quota, fileAndDirectoryCount);\n    }\n  }\n\n  /**\n   * Verify if storage space quota is violated once quota is set. Relevant\n   * method {@link DirectoryWithQuotaFeature#verifyStoragespaceQuota}.\n   * @throws DSQuotaExceededException If the quota is exceeded.\n   */\n  public void verifyStoragespaceQuota() throws DSQuotaExceededException {\n    long spaceQuota = getSpaceQuota();\n    long spaceConsumed = getSpaceConsumed();\n    if (Quota.isViolated(spaceQuota, spaceConsumed)) {\n      throw new DSQuotaExceededException(spaceQuota, spaceConsumed);\n    }\n  }\n\n  /**\n   * Verify space quota by storage type is violated once quota is set. Relevant\n   * method {@link DirectoryWithQuotaFeature#verifyQuotaByStorageType}.\n   * @throws DSQuotaExceededException If the quota is exceeded.\n   */\n  public void verifyQuotaByStorageType() throws DSQuotaExceededException {\n    for (StorageType t: StorageType.getTypesSupportingQuota()) {\n      long typeQuota = getTypeQuota(t);\n      if (typeQuota == HdfsConstants.QUOTA_RESET) {\n        continue;\n      }\n      long typeConsumed = getTypeConsumed(t);\n      if (Quota.isViolated(typeQuota, typeConsumed)) {\n        throw new DSQuotaExceededException(typeQuota, typeConsumed);\n      }","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java#L95-L131","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the space quota to at least the consumed bytes reported in the message (diskspace consumed=... B), then retry","Or free space under the path and wait for the quota cache update cycle before applying the smaller quota","Remember consumed space counts replication: estimate with file sizes x replication factor before choosing a limit"],"exampleFix":"# before\nhdfs dfs -fs hdfs://router -setSpaceQuota 100G /mount/data   # consumed = 250G -> DSQuotaExceededException\n# after\nhdfs dfs -fs hdfs://router -setSpaceQuota 300G /mount/data  # or delete ~150G+ of data first","handlingStrategy":"validation","validationCode":"// Check consumed bytes (with replication) before setting a space quota\nContentSummary cs = fs.getContentSummary(path);\nlong consumed = cs.getSpaceConsumed();\nif (spaceQuota >= 0 && spaceQuota < consumed) {\n  throw new IllegalArgumentException(\"Cannot set space quota \" + spaceQuota\n      + \" below consumed \" + consumed + \" for \" + path);\n}","typeGuard":"boolean wouldViolateSpaceQuota(long spaceQuota, long spaceConsumed) {\n  return spaceQuota >= 0 && spaceQuota < spaceConsumed; // mirrors Quota.isViolated\n}","tryCatchPattern":"try {\n  dfs.setQuota(path, HdfsConstants.QUOTA_DONT_SET, spaceQuota);\n} catch (DSQuotaExceededException dsq) {\n  // message carries quota=... and diskspace consumed=... in bytes: adjust and retry\n  LOG.warn(\"Space quota rejected: {}\", dsq.getMessage());\n  throw dsq;\n}","preventionTips":["Estimate consumption as sum(file length x replication factor); underestimating replication is the classic mistake","Delete or archive data and let the router quota cache refresh before lowering quotas","Use ContentSummary.getSpaceConsumed() as the pre-check source of truth"],"tags":["hdfs","router","federation","quota","space-quota","capacity"],"backgroundTag":"quota-exceeded","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}