{"record":{"id":"e0853035225de225","repo":"apache/hadoop","slug":"no-erasure-coding-policy-explicitly-set-on","errorCode":null,"errorMessage":"No erasure coding policy explicitly set on {}","messagePattern":"No erasure coding policy explicitly set on (.+?)","errorType":"exception","errorClass":"NoECPolicySetException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java","lineNumber":234,"sourceCode":"    FSDirectory fsd = fsn.getFSDirectory();\n    final INodesInPath iip;\n    List<XAttr> xAttrs;\n    fsd.writeLock();\n    try {\n      iip = fsd.resolvePath(pc, src, DirOp.WRITE_LINK);\n      // Write access is required to unset erasure coding policy\n      if (fsd.isPermissionEnabled()) {\n        fsd.checkPathAccess(pc, iip, FsAction.WRITE);\n      }\n      src = iip.getPath();\n      xAttrs = removeErasureCodingPolicyXAttr(fsn, iip);\n    } finally {\n      fsd.writeUnlock();\n    }\n    if (xAttrs != null) {\n      fsn.getEditLog().logRemoveXAttrs(src, xAttrs, logRetryCache);\n    } else {\n      throw new NoECPolicySetException(\n          \"No erasure coding policy explicitly set on \" + src);\n    }\n    return fsd.getAuditFileInfo(iip);\n  }\n\n  /**\n   * Add an erasure coding policy.\n   *\n   * @param fsn namespace\n   * @param policy the new policy to be added into system\n   * @param logRetryCache whether to record RPC ids in editlog for retry cache\n   *                      rebuilding\n   * @throws IOException\n   */\n  static ErasureCodingPolicy addErasureCodingPolicy(final FSNamesystem fsn,\n      ErasureCodingPolicy policy, final boolean logRetryCache) {\n    Preconditions.checkNotNull(policy);\n    ErasureCodingPolicy retPolicy =","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java#L216-L252","documentation":"NoECPolicySetException (org.apache.hadoop.hdfs.protocol.NoECPolicySetException, an IOException subclass) thrown by unsetErasureCodingPolicy when the directory has no raw.ec.policy xattr directly on itself. unsetPolicy removes only an explicit setting on that exact directory; a policy inherited from an ancestor is not 'explicitly set' and cannot be cleared from the child.","triggerScenarios":"`hdfs ec -unsetPolicy -path /ec/child` where the policy was set on /ec; unsetting a directory that never had a direct policy; running unsetPolicy a second time; unsetting a directory whose policy xattr was already removed.","commonSituations":"Assuming unset on a descendant overrides inheritance (it does not - unset only works where set was used); idempotency-sensitive automation that reruns cleanup steps; ops runbooks that unset every level of a zoned tree.","solutions":["Find where the policy is actually set: compare `hdfs ec -getPolicy` on the directory and each ancestor, then run `hdfs ec -unsetPolicy -path <that-directory>`.","In automation, catch NoECPolicySetException and treat unset as idempotent success.","Verify a direct policy exists with `hdfs dfs -getfattr -d /path` and look for the ec policy xattr (visible to authorized users)."],"exampleFix":"// before\ndfs.unsetErasureCodingPolicy(new Path(\"/ec/child\"));\n// NoECPolicySetException: policy is inherited from /ec, not explicit on /ec/child\n\n// after\ndfs.unsetErasureCodingPolicy(new Path(\"/ec\")); // unset at the dir where it was set","handlingStrategy":"try-catch","validationCode":"// Partial pre-check: a null *effective* policy (self or any ancestor) guarantees unset will throw.\nif (dfs.getErasureCodingPolicy(p) == null) {\n  // nothing set anywhere up the chain; skip unset (it would throw NoECPolicySetException)\n}","typeGuard":null,"tryCatchPattern":"import org.apache.hadoop.hdfs.protocol.NoECPolicySetException;\n\ntry {\n  dfs.unsetErasureCodingPolicy(p);\n} catch (NoECPolicySetException e) {\n  // no explicit policy on this directory: inherited from an ancestor or never set.\n  // Treat as success (idempotent unset) or walk up and unset at the real owner.\n}","preventionTips":["Remember unset only clears explicit settings; inherited policies must be unset at the ancestor that set them.","Make unset idempotent in automation by catching NoECPolicySetException.","Document which directory in each tree carries the EC policy."],"tags":["hdfs","erasure-coding","hdfs-ec","xattr","policy-inheritance"],"backgroundTag":"policy-not-set","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}