apache/hadoop · error · IOException

No matching attributes found for remove operation

Error message

No matching attributes found for remove operation

What it means

removeXAttr works from the inode's stored xattrs: unprotectedRemoveXAttrs returns the attributes that were actually removed so they can be journaled. If nothing matched, there is nothing to log and the operation throws IOException('No matching attributes found for remove operation'); the attribute simply is not set on that path.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java:186

      boolean logRetryCache) throws IOException {
    FSDirXAttrOp.checkXAttrsConfigFlag(fsd);
    XAttrPermissionFilter.checkPermissionForApi(
        pc, xAttr, FSDirectory.isReservedRawName(src));

    List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
    xAttrs.add(xAttr);
    INodesInPath iip;
    fsd.writeLock();
    try {
      iip = fsd.resolvePath(pc, src, DirOp.WRITE);
      src = iip.getPath();
      checkXAttrChangeAccess(fsd, iip, xAttr, pc);

      List<XAttr> removedXAttrs = unprotectedRemoveXAttrs(fsd, iip, xAttrs);
      if (removedXAttrs != null && !removedXAttrs.isEmpty()) {
        fsd.getEditLog().logRemoveXAttrs(src, removedXAttrs, logRetryCache);
      } else {
        throw new IOException(
            "No matching attributes found for remove operation");
      }
    } finally {
      fsd.writeUnlock();
    }
    return fsd.getAuditFileInfo(iip);
  }

  /**
   * Remove xattrs from the inode, and return the <em>removed</em> xattrs.
   * @return the <em>removed</em> xattrs.
   */
  static List<XAttr> unprotectedRemoveXAttrs(
      FSDirectory fsd, final INodesInPath iip, final List<XAttr> toRemove)
      throws IOException {
    assert fsd.hasWriteLock();
    INode inode = FSDirectory.resolveLastINode(iip);
    int snapshotId = iip.getLatestSnapshotId();

View on GitHub (pinned to 2add963021)

Solutions

  1. Check presence first with fs.listXAttrs(path) and remove only names present
  2. Make removal tolerant: catch IOException and ignore the no-matching-attributes outcome after verifying the message
  3. Prefer the exists-check plus remove pattern so the ignore branch is explicit

Example fix

// before
fs.removeXAttr(path, "user.mytag"); // throws when absent

// after
if (fs.listXAttrs(path).contains("user.mytag")) {
  fs.removeXAttr(path, "user.mytag");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (fs.listXAttrs(path).contains(name)) {
  fs.removeXAttr(path, name);
}

Try / catch

try {
  fs.removeXAttr(path, name);
} catch (IOException e) {
  if (e.getMessage() == null || !e.getMessage().contains("No matching attributes")) {
    throw e; // only swallow the absent-attribute case
  }
}

Prevention

When it happens

Trigger: fs.removeXAttr(path, name) for an xattr that is not present: never set, already removed by a previous run, or wrong namespace/name spelling.

Common situations: Idempotent cleanup code removing markers unconditionally; double-executed jobs; schema drift between the setter and the remover.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/791b968eeabdfaf1. Report an issue: GitHub.