{"record":{"id":"df7cfad52cd5886b","repo":"apache/hadoop","slug":"failed-to-rename-to-because-the-source-can-n","errorCode":null,"errorMessage":"Failed to rename {} to {} because the source can not be removed","messagePattern":"Failed to rename (.+?) to (.+?) because the source can not be removed","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java","lineNumber":755,"sourceCode":"      }\n\n      if (src.isSymlink()) {\n        srcSp = HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED;\n      } else {\n        // Update src should use src·s storage policyID\n        srcSp = src.getStoragePolicyID();\n      }\n      return srcSp == dstSp;\n    }\n\n    long removeSrc() throws IOException {\n      long removedNum = fsd.removeLastINode(srcIIP);\n      if (removedNum == -1) {\n        String error = \"Failed to rename \" + srcIIP.getPath() + \" to \" +\n            dstIIP.getPath() + \" because the source can not be removed\";\n        NameNode.stateChangeLog.warn(\"DIR* FSDirRenameOp.unprotectedRenameTo:\" +\n            error);\n        throw new IOException(error);\n      } else {\n        // update the quota count if necessary\n        Optional<QuotaCounts> countOp = sameStoragePolicy ?\n            srcSubTreeCount : Optional.empty();\n        fsd.updateCountForDelete(srcChild, srcIIP, countOp);\n        srcIIP = INodesInPath.replace(srcIIP, srcIIP.length() - 1, null);\n        return removedNum;\n      }\n    }\n\n    boolean removeSrc4OldRename() {\n      final long removedSrc = fsd.removeLastINode(srcIIP);\n      if (removedSrc == -1) {\n        NameNode.stateChangeLog.warn(\"DIR* FSDirRenameOp.unprotectedRenameTo: \"\n            + \"failed to rename \" + srcIIP.getPath() + \" to \"\n            + dstIIP.getPath() + \" because the source can not be removed\");\n        return false;\n      } else {","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java#L737-L773","documentation":"Error \"Failed to rename {} to {} because the source can not be removed\" thrown in apache/hadoop.","triggerScenarios":"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.","commonSituations":"See trigger scenarios.","solutions":["Check why the source cannot be removed (permissions, snapshots, open leases) and resolve it first.","Ensure the caller has write permission on the source's parent directory."],"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-22T20:17:22.307Z"}