apache/hadoop · error · IOException

Failed to rename {} to {} because the source can not be remo

Error message

Failed to rename {} to {} because the source can not be removed

What it means

Error "Failed to rename {} to {} because the source can not be removed" thrown in apache/hadoop.

Source

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

      }

      if (src.isSymlink()) {
        srcSp = HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED;
      } else {
        // Update src should use src·s storage policyID
        srcSp = src.getStoragePolicyID();
      }
      return srcSp == dstSp;
    }

    long removeSrc() throws IOException {
      long removedNum = fsd.removeLastINode(srcIIP);
      if (removedNum == -1) {
        String error = "Failed to rename " + srcIIP.getPath() + " to " +
            dstIIP.getPath() + " because the source can not be removed";
        NameNode.stateChangeLog.warn("DIR* FSDirRenameOp.unprotectedRenameTo:" +
            error);
        throw new IOException(error);
      } else {
        // update the quota count if necessary
        Optional<QuotaCounts> countOp = sameStoragePolicy ?
            srcSubTreeCount : Optional.empty();
        fsd.updateCountForDelete(srcChild, srcIIP, countOp);
        srcIIP = INodesInPath.replace(srcIIP, srcIIP.length() - 1, null);
        return removedNum;
      }
    }

    boolean removeSrc4OldRename() {
      final long removedSrc = fsd.removeLastINode(srcIIP);
      if (removedSrc == -1) {
        NameNode.stateChangeLog.warn("DIR* FSDirRenameOp.unprotectedRenameTo: "
            + "failed to rename " + srcIIP.getPath() + " to "
            + dstIIP.getPath() + " because the source can not be removed");
        return false;
      } else {

View on GitHub (pinned to 2add963021)

Solutions

  1. Check why the source cannot be removed (permissions, snapshots, open leases) and resolve it first.
  2. Ensure the caller has write permission on the source's parent directory.

When it happens

Trigger: Rename fails because the source inode (or one of its descendants) cannot be removed from its parent, e.g. it is referenced by a snapshot.

Common situations: See trigger scenarios.


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