{"record":{"id":"658a4858b3cab9e4","repo":"apache/hadoop","slug":"quota-by-storage-type-type-on-path-pathname-is","errorCode":null,"errorMessage":"Quota by storage type : type on path : pathName is exceeded. quota = long2String(quota, \"B\", 2) but space consumed = long2String(count, \"B\", 2)","messagePattern":"Quota by storage type : type on path : pathName is exceeded\\. quota = long2String\\(quota, \"B\", 2\\) but space consumed = long2String\\(count, \"B\", 2\\)","errorType":"exception","errorClass":"QuotaByStorageTypeExceededException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/DirectoryWithQuotaFeature.java","lineNumber":200,"sourceCode":"  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      }\n    }\n  }\n\n  /**\n   * @throws QuotaExceededException if namespace, storagespace or storage type\n   * space quota is violated after applying the deltas.\n   */\n  void verifyQuota(QuotaCounts counts) throws QuotaExceededException {\n    verifyNamespaceQuota(counts.getNameSpace());\n    verifyStoragespaceQuota(counts.getStorageSpace());\n    verifyQuotaByStorageType(counts.getTypeSpaces());\n  }\n\n  boolean isQuotaSet() {\n    return quota.anyNsSsCountGreaterOrEqual(0) ||\n        quota.anyTypeSpaceCountGreaterOrEqual(0);","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/DirectoryWithQuotaFeature.java#L182-L218","documentation":"QuotaByStorageTypeExceededException thrown from verifyQuotaByStorageType(), which iterates StorageType.getTypesSupportingQuota() and rejects a write when quota.getTypeSpace(t) is set and usage + typeDelta exceeds it for any type. Per-type quotas are set with 'hdfs dfsadmin -setSpaceQuota -t <TYPE> <N> <path>' and gate how many bytes of a file's blocks may live on a specific tier (DISK/SSD/ARCHIVE), as steered by the path's storage policy.","triggerScenarios":"Writing files under a directory whose storage policy (e.g., COLD -> ARCHIVE, ALL_SSD -> SSD) routes new blocks to a tier where the type quota is set and consumed + delta > quota; calling setStoragePolicy on a path then appending so new blocks land on the capped tier; distcp copying hot data into a COLD directory with an ARCHIVE quota.","commonSituations":"Tiered clusters (SSD hot tier / ARCHIVE cold tier) with per-type budgets; storage policy changed by an admin after quotas were sized; replication also multiplies per-type usage; verify current numbers with 'hdfs dfs -count -t <types> <path>' or getQuotaUsage().","solutions":["Raise the type quota: hdfs dfsadmin -setSpaceQuota -t ARCHIVE 5T <path> (repeat per type as needed).","Change the storage policy so new writes target a tier with headroom: hdfs dfsadmin -setStoragePolicy -path <path> -policy HOT, then verify with -getStoragePolicy.","Delete or compact data on the saturated tier under the path.","Check current per-type usage first: hdfs dfs -count -t SSD,DISK,ARCHIVE <path>."],"exampleFix":"# before\nhdfs dfsadmin -setStoragePolicy -path /cold -policy COLD\nhdfs dfsadmin -setSpaceQuota -t ARCHIVE 500G /cold   # distcp fills it\n# after\nhdfs dfsadmin -setSpaceQuota -t ARCHIVE 2T /cold\nhdfs dfs -count -t ARCHIVE /cold","handlingStrategy":"validation","validationCode":"QuotaUsage q = dfs.getQuotaUsage(dir);\nString policy = dfs.getStoragePolicy(dir).getName();   // e.g. COLD -> ARCHIVE\nStorageType tier = policy.equals(\"COLD\") ? StorageType.ARCHIVE : StorageType.DISK;\nif (q.getTypeQuota(tier) >= 0\n    && q.getTypeConsumed(tier) + bytes * replication > q.getTypeQuota(tier)) {\n  // raise -setSpaceQuota -t <tier>, change policy, or shed data first\n}","typeGuard":"static boolean isTypeQuotaExceeded(IOException e) {\n  return e instanceof QuotaByStorageTypeExceededException\n      || (e instanceof RemoteException re\n          && re.getClassName().endsWith(\"QuotaByStorageTypeExceededException\"));\n}","tryCatchPattern":"try {\n  fs.create(dst);\n} catch (RemoteException re) {\n  if (re.getClassName().endsWith(\"QuotaByStorageTypeExceededException\")) {\n    // tier is full: raise the type quota or setStoragePolicy to a tier with headroom\n  } else { throw re; }\n}","preventionTips":["Track storage policy AND per-type quotas together: policy decides which tier quota the write hits.","Check hdfs dfs -count -t <types> <path> before large writes into tiered directories.","Remember replication multiplies per-type consumption too.","Alert per tier (SSD/DISK/ARCHIVE) separately from total space."],"tags":["hdfs","quota","storage-type","storage-policy","tiering"],"backgroundTag":"hdfs-quota-exceeded","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}