{"record":{"id":"628f151185e69365","repo":"apache/hadoop","slug":"don-t-support-quota-for-storage-type","errorCode":null,"errorMessage":"Don't support Quota for storage type : {}","messagePattern":"Don't support Quota for storage type : (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java","lineNumber":2682,"sourceCode":"  }\n\n  /**\n   * Sets or resets quotas by storage type for a directory.\n   * @see ClientProtocol#setQuota(String, long, long, StorageType)\n   */\n  void setQuotaByStorageType(String src, StorageType type, long quota)\n      throws IOException {\n    checkOpen();\n    if (quota <= 0 && quota != HdfsConstants.QUOTA_DONT_SET &&\n        quota != HdfsConstants.QUOTA_RESET) {\n      throw new IllegalArgumentException(\"Invalid values for quota :\" +\n          quota);\n    }\n    if (type == null) {\n      throw new IllegalArgumentException(\"Invalid storage type(null)\");\n    }\n    if (!type.supportTypeQuota()) {\n      throw new IllegalArgumentException(\n          \"Don't support Quota for storage type : \" + type.toString());\n    }\n    try (TraceScope ignored = newPathTraceScope(\"setQuotaByStorageType\", src)) {\n      namenode.setQuota(src, HdfsConstants.QUOTA_DONT_SET, quota, type);\n    } catch (RemoteException re) {\n      throw re.unwrapRemoteException(AccessControlException.class,\n          FileNotFoundException.class,\n          QuotaByStorageTypeExceededException.class,\n          UnresolvedPathException.class,\n          SnapshotAccessControlException.class);\n    }\n  }\n\n  /**\n   * set the modification and access time of a file.\n   *\n   * @see ClientProtocol#setTimes(String, long, long)\n   */","sourceCodeStart":2664,"sourceCodeEnd":2700,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java#L2664-L2700","documentation":"Even a non-null StorageType can be ineligible: StorageType.supportTypeQuota() returns !isTransient(), and RAM_DISK is the transient type (in-memory, evicted to DISK). setQuotaByStorageType therefore rejects RAM_DISK client-side with IllegalArgumentException — transient storage cannot carry a quota because its contents are by definition temporary.","triggerScenarios":"Calling setQuotaByStorageType with StorageType.RAM_DISK directly, or generic tooling that iterates StorageType.values() and applies quotas to every entry without filtering transient types.","commonSituations":"Cluster-admin scripts that 'normalize' quotas across all storage types; enablement of LAZY_PERSIST/RAM_DISK tiers followed by blanket quota rollout; test matrices sweeping all enum values.","solutions":["Filter before calling: apply quotas only where type.supportTypeQuota() is true.","If you genuinely hit it with RAM_DISK, drop the intent — transient storage is not quota-able; manage capacity via dfs.datanode... max ram cache settings instead.","Fix hardcoded type lists that include RAM_DISK."],"exampleFix":"// before\nfor (StorageType t : StorageType.values()) {\n  client.setQuotaByStorageType(dir, t, quota); // throws for RAM_DISK\n}\n\n// after\nfor (StorageType t : StorageType.values()) {\n  if (t.supportTypeQuota()) {\n    client.setQuotaByStorageType(dir, t, quota);\n  }\n}","handlingStrategy":"validation","validationCode":"if (!type.supportTypeQuota()) {\n  // transient type (RAM_DISK): quotas not supported, skip instead of calling\n} else {\n  client.setQuotaByStorageType(dir, type, quota);\n}","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Don't support Quota\")) {\n    // filter this storage type out of the rollout and continue\n  } else { throw e; }\n}","preventionTips":["Always filter with StorageType.supportTypeQuota() before applying quotas in bulk.","Treat RAM_DISK capacity management as a DataNode memory config concern, not a quota concern.","Keep blanket 'apply to all types' scripts out of clusters with transient tiers enabled."],"tags":["hdfs","quota","storage-type","ram-disk","unsupported-operation"],"backgroundTag":"unsupported-storage-type","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}