{"record":{"id":"462768889c39f26b","repo":"apache/hadoop","slug":"the-diskspace-quota-of-pathname-is-exceeded-quota","errorCode":null,"errorMessage":"The DiskSpace quota of pathName is exceeded: quota = quota B = long2String(quota, \"B\", 2) but diskspace consumed = count B = long2String(count, \"B\", 2)","messagePattern":"The DiskSpace quota of pathName is exceeded: quota = quota B = long2String\\(quota, \"B\", 2\\) but diskspace consumed = count B = long2String\\(count, \"B\", 2\\)","errorType":"exception","errorClass":"DSQuotaExceededException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/DirectoryWithQuotaFeature.java","lineNumber":184,"sourceCode":"    return new QuotaCounts.Builder().quotaCount(quota).build();\n  }\n\n  /** @return the namespace and storagespace and typespace consumed. */\n  public QuotaCounts getSpaceConsumed() {\n    return new QuotaCounts.Builder().quotaCount(usage).build();\n  }\n\n  /** Verify if the namespace quota is violated after applying delta. */\n  private void verifyNamespaceQuota(long delta) throws NSQuotaExceededException {\n    if (Quota.isViolated(quota.getNameSpace(), usage.getNameSpace(), delta)) {\n      throw new NSQuotaExceededException(quota.getNameSpace(),\n          usage.getNameSpace() + delta);\n    }\n  }\n  /** Verify if the storagespace quota is violated after applying delta. */\n  private void verifyStoragespaceQuota(long delta) throws DSQuotaExceededException {\n    if (Quota.isViolated(quota.getStorageSpace(), usage.getStorageSpace(), delta)) {\n      throw new DSQuotaExceededException(quota.getStorageSpace(),\n          usage.getStorageSpace() + delta);\n    }\n  }\n\n  private void verifyQuotaByStorageType(EnumCounters<StorageType> typeDelta)\n      throws QuotaByStorageTypeExceededException {\n    if (!isQuotaByStorageTypeSet()) {\n      return;\n    }\n    for (StorageType t: StorageType.getTypesSupportingQuota()) {\n      if (!isQuotaByStorageTypeSet(t)) {\n        continue;\n      }\n      if (Quota.isViolated(quota.getTypeSpace(t), usage.getTypeSpace(t),\n          typeDelta.get(t))) {\n        throw new QuotaByStorageTypeExceededException(\n          quota.getTypeSpace(t), usage.getTypeSpace(t) + typeDelta.get(t), t);\n      }","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/DirectoryWithQuotaFeature.java#L166-L202","documentation":"DSQuotaExceededException thrown from verifyStoragespaceQuota(): the storage-space quota (bytes, set with 'hdfs dfsadmin -setSpaceQuota') would be exceeded after applying delta, i.e. Quota.isViolated(quota.getStorageSpace(), usage.getStorageSpace(), delta). The check runs on every write that grows disk usage; crucially HDFS counts bytes multiplied by replication factor.","triggerScenarios":"create()/addBlock/appending a block under a space-quota'd directory: the delta is blockReplication * blockSize (default 3x block size per block allocated); rename of a data-bearing subtree into the quota'd tree; setrep raising usage retroactively on later writes.","commonSituations":"Quota sized to raw bytes while default replication x3 triples consumption; raising replication on existing files inside a quota'd area; large sequential writers hitting the ceiling mid-job; distcp preserving replication into a quota'd destination.","solutions":["Raise or clear the space quota: hdfs dfsadmin -setSpaceQuota 500G <path> or hdfs dfsadmin -clrSpaceQuota <path>.","Lower replication under the path: hdfs dfs -setrep -w 2 <path> (frees 1x of usage from the quota accounting).","Delete or archive data under the path until usage < quota.","Budget writes in advance: needed = bytes * replication; compare against hdfs dfs -count -q output (SPACE_QUOTA, REMAINING_SPACE_QUOTA)."],"exampleFix":"# before\nhdfs dfsadmin -setSpaceQuota 1T /data/warehouse   # writes replicate x3\n# after: budget 3x, or lower replication\nhdfs dfsadmin -setSpaceQuota 3T /data/warehouse\nhdfs dfs -setrep -w 2 /data/warehouse/cold","handlingStrategy":"validation","validationCode":"ContentSummary cs = dfs.getContentSummary(dir);\nshort rep = fs.getFileStatus(dst).getReplication();\nlong need = bytesToWrite * rep;                     // replication multiplies usage\nif (cs.getSpaceQuota() >= 0 && cs.getSpaceConsumed() + need > cs.getSpaceQuota()) {\n  // raise -setSpaceQuota, lower replication, or shed data BEFORE writing\n}","typeGuard":"static boolean isSpaceQuotaExceeded(IOException e) {\n  return e instanceof DSQuotaExceededException\n      || (e instanceof RemoteException re\n          && re.getClassName().endsWith(\"DSQuotaExceededException\"));\n}","tryCatchPattern":"try {\n  out = fs.create(dst);\n} catch (RemoteException re) {\n  if (re.getClassName().endsWith(\"DSQuotaExceededException\")) {\n    // stop producing, raise space quota or reduce replication, resume from last checkpoint\n  } else { throw re; }\n}","preventionTips":["Budget quota math as bytes * replicationFactor (default x3).","Monitor SPACE_QUOTA/REMAINING_SPACE_QUOTA from hdfs dfs -count -q or ContentSummary and alert before saturation.","Pre-lower replication (hdfs dfs -setrep) for cold data instead of discovering the limit mid-write.","Make writers resumable (write to temp, checkpoint offsets) so a quota hit is not fatal."],"tags":["hdfs","quota","diskspace","replication","dfsadmin"],"backgroundTag":"hdfs-quota-exceeded","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}