apache/hadoop · error · IllegalArgumentException

Invalid values for quota : {} and {}

Error message

Invalid values for quota : {} and {}

What it means

DFSClient.setQuota validates before the RPC: the namespace quota must be positive or one of the sentinels HdfsConstants.QUOTA_DONT_SET (Long.MAX_VALUE, leave unchanged) / QUOTA_RESET (-1, clear), and the storage-space quota must be non-negative or the same sentinels. Anything else — notably 0 for namespace (not a sentinel here) or negatives other than -1 — throws IllegalArgumentException.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java:2647

      }
    }
  }

  /**
   * Sets or resets quotas for a directory.
   * @see ClientProtocol#setQuota(String, long, long, StorageType)
   */
  void setQuota(String src, long namespaceQuota, long storagespaceQuota)
      throws IOException {
    checkOpen();
    // sanity check
    if ((namespaceQuota <= 0 &&
          namespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
          namespaceQuota != HdfsConstants.QUOTA_RESET) ||
        (storagespaceQuota < 0 &&
            storagespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
            storagespaceQuota != HdfsConstants.QUOTA_RESET)) {
      throw new IllegalArgumentException("Invalid values for quota : " +
          namespaceQuota + " and " +
          storagespaceQuota);

    }
    try (TraceScope ignored = newPathTraceScope("setQuota", src)) {
      // Pass null as storage type for traditional namespace/storagespace quota.
      namenode.setQuota(src, namespaceQuota, storagespaceQuota, null);
    } catch (RemoteException re) {
      throw re.unwrapRemoteException(AccessControlException.class,
          FileNotFoundException.class,
          NSQuotaExceededException.class,
          DSQuotaExceededException.class,
          QuotaByStorageTypeExceededException.class,
          UnresolvedPathException.class,
          SnapshotAccessControlException.class);
    }
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Express intent with the sentinels explicitly: HdfsConstants.QUOTA_DONT_SET to leave a quota unchanged, HdfsConstants.QUOTA_RESET (-1) to clear it, positive values to set it.
  2. Validate at your boundary before calling: namespace must be > 0 or a sentinel; space must be >= 0 or a sentinel.
  3. Check arithmetic that derives quotas (deltas, subtractions) for underflow.

Example fix

// before
client.setQuota(dir, nsQuota, spQuota); // nsQuota = 0 or -2 -> IllegalArgumentException

// after
long ns = (nsQuota < 0) ? HdfsConstants.QUOTA_RESET : nsQuota; // set: >0, reset: -1
long sp = (spQuota < 0) ? HdfsConstants.QUOTA_RESET : spQuota; // >= 0 to set
client.setQuota(dir, ns, sp);
Defensive patterns

Strategy: validation

Validate before calling

boolean okNs = nsQ > 0 || nsQ == HdfsConstants.QUOTA_DONT_SET || nsQ == HdfsConstants.QUOTA_RESET;
boolean okSp = spQ >= 0 || spQ == HdfsConstants.QUOTA_DONT_SET || spQ == HdfsConstants.QUOTA_RESET;
if (!(okNs && okSp)) {
  throw new IllegalArgumentException("quota out of range: " + nsQ + ", " + spQ);
}

Try / catch

catch (IllegalArgumentException e) {
  // surface the rejected quota pair to the config owner; do not blanket-retry
}

Prevention

When it happens

Trigger: Calling setQuota with values like -5, Long.MIN_VALUE sentinel mistakes, or 0 used for namespace 'unlimited'; wrappers mapping user strings ('none', 'inherit', '-1') to longs incorrectly; arithmetic that computes quota deltas underflowing.

Common situations: Quota automation mapping UI/config vocabulary to numeric values; teams assuming 0 means 'no quota' because older CLIs behaved differently in printouts; scripts resetting quotas with the wrong constant.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/a1d335c5e66bda1e. Report an issue: GitHub.