apache/hadoop · error · NoECPolicySetException
No erasure coding policy explicitly set on {}
Error message
No erasure coding policy explicitly set on {} What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java:234
FSDirectory fsd = fsn.getFSDirectory();
final INodesInPath iip;
List<XAttr> xAttrs;
fsd.writeLock();
try {
iip = fsd.resolvePath(pc, src, DirOp.WRITE_LINK);
// Write access is required to unset erasure coding policy
if (fsd.isPermissionEnabled()) {
fsd.checkPathAccess(pc, iip, FsAction.WRITE);
}
src = iip.getPath();
xAttrs = removeErasureCodingPolicyXAttr(fsn, iip);
} finally {
fsd.writeUnlock();
}
if (xAttrs != null) {
fsn.getEditLog().logRemoveXAttrs(src, xAttrs, logRetryCache);
} else {
throw new NoECPolicySetException(
"No erasure coding policy explicitly set on " + src);
}
return fsd.getAuditFileInfo(iip);
}
/**
* Add an erasure coding policy.
*
* @param fsn namespace
* @param policy the new policy to be added into system
* @param logRetryCache whether to record RPC ids in editlog for retry cache
* rebuilding
* @throws IOException
*/
static ErasureCodingPolicy addErasureCodingPolicy(final FSNamesystem fsn,
ErasureCodingPolicy policy, final boolean logRetryCache) {
Preconditions.checkNotNull(policy);
ErasureCodingPolicy retPolicy =View on GitHub (pinned to 2add963021)
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).
Example fix
// before
dfs.unsetErasureCodingPolicy(new Path("/ec/child"));
// NoECPolicySetException: policy is inherited from /ec, not explicit on /ec/child
// after
dfs.unsetErasureCodingPolicy(new Path("/ec")); // unset at the dir where it was set Defensive patterns
Strategy: try-catch
Validate before calling
// Partial pre-check: a null *effective* policy (self or any ancestor) guarantees unset will throw.
if (dfs.getErasureCodingPolicy(p) == null) {
// nothing set anywhere up the chain; skip unset (it would throw NoECPolicySetException)
} Try / catch
import org.apache.hadoop.hdfs.protocol.NoECPolicySetException;
try {
dfs.unsetErasureCodingPolicy(p);
} catch (NoECPolicySetException e) {
// no explicit policy on this directory: inherited from an ancestor or never set.
// Treat as success (idempotent unset) or walk up and unset at the real owner.
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- Path not found: {}
- Policy '%s' does not match any enabled erasure coding polici
- The given erasure coding policy {} does not exist.
- Attempt to set an erasure coding policy for a file {}
- Cannot unset an erasure coding policy on a file {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e0853035225de225.
Report an issue: GitHub.