apache/hadoop · error · NSQuotaExceededException
The NameSpace quota (directories and files) is exceeded: quo
Error message
The NameSpace quota (directories and files) is exceeded: quota={} file count={} What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java:100
}
@Override
public Builder typeQuota(StorageType type, long quota) {
super.typeQuota(type, quota);
return this;
}
}
/**
* Verify if namespace quota is violated once quota is set. Relevant
* method {@link DirectoryWithQuotaFeature#verifyNamespaceQuota}.
* @throws NSQuotaExceededException If the quota is exceeded.
*/
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. RelevantView on GitHub (pinned to 2add963021)
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
Example fix
# before: usage already above the requested quota hdfs dfs -fs hdfs://router -setQuota 1000 /mount/data # The NameSpace quota ... quota=1000 file count=5000 # after hdfs dfs -fs hdfs://router -setQuota 10000 /mount/data # or clean up 4000+ entries first
Defensive patterns
Strategy: validation
Validate before calling
// Compare requested quota against current usage before calling setQuota
ContentSummary cs = fs.getContentSummary(path);
long current = cs.getFileAndDirectoryCount();
if (quotaNs >= 0 && quotaNs < current) {
throw new IllegalArgumentException("Cannot set namespace quota " + quotaNs
+ " below current count " + current + " for " + path);
} Type guard
boolean wouldViolateNamespaceQuota(long quota, long fileAndDirCount) {
return quota >= 0 && quota < fileAndDirCount; // mirrors Quota.isViolated
} Try / catch
try {
dfs.setQuota(path, quotaNs, quotaDs);
} catch (NSQuotaExceededException nsq) {
// message carries quota=... file count=... : raise quota or clean up, then retry
LOG.warn("Namespace quota rejected: {}", nsq.getMessage());
throw nsq;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- The DiskSpace quota is exceeded: quota = {} B = {} but disks
- Router quota manager is not initialized.
- Mount table state store is not available.
- Exceeded the configured number of objects {} in the filesyst
- No mount point for %s
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/94b889ce1f60dbd3.
Report an issue: GitHub.