{"record":{"id":"143b090ae4490e00","repo":"apache/hadoop","slug":"unable-to-rename-src-to-dst","errorCode":null,"errorMessage":"Unable to rename {src} to {dst}","messagePattern":"Unable to rename (.+?) to (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/MapTask.java","lineNumber":2040,"sourceCode":"     * Rename srcPath to dstPath on the same volume. This is the same\n     * as RawLocalFileSystem's rename method, except that it will not\n     * fall back to a copy, and it will create the target directory\n     * if it doesn't exist.\n     */\n    private void sameVolRename(Path srcPath,\n        Path dstPath) throws IOException {\n      RawLocalFileSystem rfs = (RawLocalFileSystem)this.rfs;\n      File src = rfs.pathToFile(srcPath);\n      File dst = rfs.pathToFile(dstPath);\n      if (!dst.getParentFile().exists()) {\n        if (!dst.getParentFile().mkdirs()) {\n          throw new IOException(\"Unable to rename \" + src + \" to \"\n              + dst + \": couldn't create parent directory\");\n        }\n      }\n      \n      if (!src.renameTo(dst)) {\n        throw new IOException(\"Unable to rename \" + src + \" to \" + dst);\n      }\n    }\n\n    /**\n     * Increments numSpills local counter by taking into consideration\n     * the max limit on spill files being generated by the job.\n     * If limit is reached, this function throws an IOException\n     */\n    private void incrementNumSpills() throws IOException {\n      ++numSpills;\n      if(spillFilesCountLimit != SPILL_FILES_COUNT_UNBOUNDED_LIMIT_VALUE\n          && numSpills > spillFilesCountLimit) {\n        throw new IOException(\"Too many spill files got created, control it with \" +\n            \"mapreduce.task.spill.files.count.limit, current value: \" + spillFilesCountLimit +\n            \", current spill count: \" + numSpills);\n      }\n    }\n  } // MapOutputBuffer","sourceCodeStart":2022,"sourceCodeEnd":2058,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/MapTask.java#L2022-L2058","documentation":"The single-spill fast path renames the spill file (and its index) to the final output files on the same volume using File.renameTo(). If the OS refuses the rename - destination already exists, permission denied, source vanished, or (on Windows) an open handle on the target - this IOException names both paths.","triggerScenarios":"File.renameTo returns false during mergeParts' numSpills==1 promotion: stale output file left from prior attempt residue in the attempt dir, source spill file already deleted by cleanup races, EACCES on the directory, or an open handle on Windows.","commonSituations":"Leftover files in attempt output dirs after NM restarts or interrupted attempts; antivirus/backup software holding handles on Windows; unwritable directory ownership; source removed mid-finalization.","solutions":["Inspect both paths from the message on the node: does the destination already exist? does the source still exist?","Clear stale attempt directories under the NM local dirs and rerun the job","Verify the attempt directory is owned by the task user and writable","On Windows nodes, exclude Hadoop local dirs from antivirus scanning"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep NM local dirs clean of stale attempt directories between job runs","On Windows, exclude Hadoop local dirs from antivirus/backup scanners that hold rename-blocking handles","When porting this pattern into your own code, use FileSystem.rename (with fallback semantics) rather than raw File.renameTo"],"tags":["hadoop","mapreduce","rename","spill","local-filesystem"],"backgroundTag":"file-rename-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}