{"record":{"id":"94b889ce1f60dbd3","repo":"apache/hadoop","slug":"the-namespace-quota-directories-and-files-is-exc","errorCode":null,"errorMessage":"The NameSpace quota (directories and files) is exceeded: quota={} file count={}","messagePattern":"The NameSpace quota \\(directories and files\\) is exceeded: quota=(.+?) file count=(.+?)","errorType":"exception","errorClass":"NSQuotaExceededException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java","lineNumber":100,"sourceCode":"    }\n\n    @Override\n    public Builder typeQuota(StorageType type, long quota) {\n      super.typeQuota(type, quota);\n      return this;\n    }\n  }\n\n  /**\n   * Verify if namespace quota is violated once quota is set. Relevant\n   * method {@link DirectoryWithQuotaFeature#verifyNamespaceQuota}.\n   * @throws NSQuotaExceededException If the quota is exceeded.\n   */\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","sourceCodeStart":82,"sourceCodeEnd":118,"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#L82-L118","documentation":"RouterQuotaUsage.verifyNamespaceQuota mirrors Namenode-side DirectoryWithQuotaFeature.verifyNamespaceQuota: when setting a namespace quota through the router, it compares the requested quota with the current file-and-directory count aggregated for the federated path (Quota.isViolated). If the quota would already be violated by existing content, it throws NSQuotaExceededException with quota and file count in the message.","triggerScenarios":"Setting a namespace quota (hdfs dfs -setQuota <N> <path> via the router, or setQuota RPC) where N is smaller than the current fileAndDirectoryCount reported for the mount point - the router aggregates usage from the subclusters and rejects the operation before it reaches them.","commonSituations":"Shrinking quotas below existing usage during capacity management; setting quota on a mount whose subcluster usage grew since the last quota-cache refresh (stale RouterQuotaUpdateService numbers); typos in quota magnitude (KB vs count confusion).","solutions":["Raise the quota to at least the current file+directory count shown in the exception (file count=...), then re-run setQuota","Or reduce usage first: delete/archive files and directories under the path, wait for the router quota cache to refresh (dfs.federation.router.quota.cache.update.interval), then set the lower quota","If the counts look wrong, check RouterQuotaUpdateService health/state store - stale usage data causes false rejections"],"exampleFix":"# before: usage already above the requested quota\nhdfs dfs -fs hdfs://router -setQuota 1000 /mount/data   # The NameSpace quota ... quota=1000 file count=5000\n# after\nhdfs dfs -fs hdfs://router -setQuota 10000 /mount/data  # or clean up 4000+ entries first","handlingStrategy":"validation","validationCode":"// Compare requested quota against current usage before calling setQuota\nContentSummary cs = fs.getContentSummary(path);\nlong current = cs.getFileAndDirectoryCount();\nif (quotaNs >= 0 && quotaNs < current) {\n  throw new IllegalArgumentException(\"Cannot set namespace quota \" + quotaNs\n      + \" below current count \" + current + \" for \" + path);\n}","typeGuard":"boolean wouldViolateNamespaceQuota(long quota, long fileAndDirCount) {\n  return quota >= 0 && quota < fileAndDirCount; // mirrors Quota.isViolated\n}","tryCatchPattern":"try {\n  dfs.setQuota(path, quotaNs, quotaDs);\n} catch (NSQuotaExceededException nsq) {\n  // message carries quota=... file count=... : raise quota or clean up, then retry\n  LOG.warn(\"Namespace quota rejected: {}\", nsq.getMessage());\n  throw nsq;\n}","preventionTips":["Read ContentSummary (fileAndDirectoryCount) before shrinking quotas","Account for the router quota cache refresh lag: usage may be minutes old","Alert on mounts whose usage approaches quota so setters act before thresholds are crossed"],"tags":["hdfs","router","federation","quota","namespace-quota","capacity"],"backgroundTag":"quota-exceeded","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}