{"record":{"id":"a6c098b892b1104b","repo":"apache/hadoop","slug":"system-erasure-coding-policy-name-cannot","errorCode":null,"errorMessage":"\"System erasure coding policy \" + name + \" cannot be removed\"","messagePattern":"\"System erasure coding policy \" \\+ name \\+ \" cannot be removed\"","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":379,"sourceCode":"  private byte getNextAvailablePolicyID() {\n    byte nextPolicyID = (byte)(getCurrentMaxPolicyID() + 1);\n    return nextPolicyID > ErasureCodeConstants.USER_DEFINED_POLICY_START_ID ?\n        nextPolicyID : ErasureCodeConstants.USER_DEFINED_POLICY_START_ID;\n  }\n\n  /**\n   * Remove an User erasure coding policy by policyName.\n   */\n  public synchronized void removePolicy(String name) {\n    final ErasureCodingPolicyInfo info = policiesByName.get(name);\n    if (info == null) {\n      throw new HadoopIllegalArgumentException(\"The policy name \" +\n          name + \" does not exist\");\n    }\n\n    final ErasureCodingPolicy ecPolicy = info.getPolicy();\n    if (ecPolicy.isSystemPolicy()) {\n      throw new HadoopIllegalArgumentException(\"System erasure coding policy \" +\n          name + \" cannot be removed\");\n    }\n\n    if (enabledPoliciesByName.containsKey(name)) {\n      enabledPoliciesByName.remove(name);\n      enabledPolicies =\n          enabledPoliciesByName.values().toArray(new ErasureCodingPolicy[0]);\n    }\n    info.setState(ErasureCodingPolicyState.REMOVED);\n    LOG.info(\"Remove erasure coding policy \" + name);\n    allPersistedPolicies.put(ecPolicy.getId(),\n        createPolicyInfo(ecPolicy, ErasureCodingPolicyState.REMOVED));\n    /*\n     * TODO HDFS-12405 postpone the delete removed policy to Namenode restart\n     * time.\n     * */\n  }\n","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java#L361-L397","documentation":"Error \"\"System erasure coding policy \" + name + \" cannot be removed\"\" thrown in apache/hadoop.","triggerScenarios":"Attempting to remove one of the built-in system erasure coding policies (e.g. RS-6-3-1024k), which may only be disabled, not removed.","commonSituations":"See trigger scenarios.","solutions":["Do not attempt to remove built-in system EC policies; only user-added policies can be removed.","If the goal is to disallow use, disable the policy instead of removing it."],"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-23T01:17:44.959Z"}