{"record":{"id":"421ab69977145fdf","repo":"apache/hadoop","slug":"adding-erasure-coding-policy-failed-because-the-n","errorCode":null,"errorMessage":"\"Adding erasure coding policy failed because the number of policies stored in the system already reached the threshold, which is \" + ErasureCodeConstants.MAX_POLICY_ID","messagePattern":"\"Adding erasure coding policy failed because the number of policies stored in the system already reached the threshold, which is \" \\+ ErasureCodeConstants\\.MAX_POLICY_ID","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java","lineNumber":338,"sourceCode":"    String assignedNewName = ErasureCodingPolicy.composePolicyName(\n        policy.getSchema(), policy.getCellSize());\n    for (ErasureCodingPolicyInfo info : getPolicies()) {\n      final ErasureCodingPolicy p = info.getPolicy();\n      if (p.getName().equals(assignedNewName)) {\n        LOG.info(\"The policy name \" + assignedNewName + \" already exists\");\n        return p;\n      }\n      if (p.getSchema().equals(policy.getSchema()) &&\n          p.getCellSize() == policy.getCellSize()) {\n        LOG.info(\"A policy with same schema \"\n            + policy.getSchema().toString() + \" and cell size \"\n            + p.getCellSize() + \" already exists\");\n        return p;\n      }\n    }\n\n    if (getCurrentMaxPolicyID() == ErasureCodeConstants.MAX_POLICY_ID) {\n      throw new HadoopIllegalArgumentException(\"Adding erasure coding \" +\n          \"policy failed because the number of policies stored in the \" +\n          \"system already reached the threshold, which is \" +\n          ErasureCodeConstants.MAX_POLICY_ID);\n    }\n\n    policy = new ErasureCodingPolicy(assignedNewName, policy.getSchema(),\n        policy.getCellSize(), getNextAvailablePolicyID());\n    final ErasureCodingPolicyInfo pi = new ErasureCodingPolicyInfo(policy);\n    this.policiesByName.put(policy.getName(), pi);\n    this.policiesByID.put(policy.getId(), pi);\n    allPolicies =\n        policiesByName.values().toArray(new ErasureCodingPolicyInfo[0]);\n    allPersistedPolicies.put(policy.getId(),\n        new ErasureCodingPolicyInfo(policy));\n    LOG.info(\"Added erasure coding policy \" + policy);\n    return policy;\n  }\n","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java#L320-L356","documentation":"Error \"\"Adding erasure coding policy failed because the number of policies stored in the system already reached the threshold, which is \" + ErasureCodeConstants.MAX_POLICY_ID\" thrown in apache/hadoop.","triggerScenarios":"Adding a new erasure coding policy when the number of user-defined policies already reached ErasureCodeConstants.MAX_POLICY_ID, leaving no free policy IDs.","commonSituations":"See trigger scenarios.","solutions":["Remove unused user-defined EC policies before adding new ones.","Reuse an existing policy instead of creating a new one; the number of policies is bounded by ErasureCodeConstants.MAX_POLICY_ID."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}