{"record":{"id":"ee5f76d941678d4c","repo":"apache/hadoop","slug":"unable-to-rename-to","errorCode":null,"errorMessage":"Unable to rename {} to {}","messagePattern":"Unable to rename (.+?) to (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImagePreTransactionalStorageInspector.java","lineNumber":237,"sourceCode":"        // before the namenode crashed.\n        //\n        if (!ckptFile.delete()) {\n          throw new IOException(\"Unable to delete \" + ckptFile);\n        }\n      } else {\n        //\n        // checkpointing was in progress when the namenode\n        // shutdown. The fsimage.ckpt was created and the edits.new\n        // file was moved to edits. We complete that checkpoint by\n        // moving fsimage.new to fsimage. There is no need to \n        // update the fstime file here. renameTo fails on Windows\n        // if the destination file already exists.\n        //\n        if (!ckptFile.renameTo(curFile)) {\n          if (!curFile.delete())\n            LOG.warn(\"Unable to delete dir \" + curFile + \" before rename\");\n          if (!ckptFile.renameTo(curFile)) {\n            throw new IOException(\"Unable to rename \" + ckptFile +\n                                  \" to \" + curFile);\n          }\n        }\n      }\n    }\n    return needToSave;\n  }\n  \n  /**\n   * @return a list with the paths to EDITS and EDITS_NEW (if it exists)\n   * in a given storage directory.\n   */\n  static List<File> getEditsInStorageDir(StorageDirectory sd) {\n    ArrayList<File> files = new ArrayList<File>();\n    File edits = NNStorage.getStorageFile(sd, NameNodeFile.EDITS);\n    assert edits.exists() : \"Expected edits file at \" + edits;\n    files.add(edits);\n    File editsNew = NNStorage.getStorageFile(sd, NameNodeFile.EDITS_NEW);","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImagePreTransactionalStorageInspector.java#L219-L255","documentation":"Complementary recovery path in the pre-transactional inspector: fsimage.ckpt exists but edits.new is gone (the interrupted checkpoint got further), so recovery completes the checkpoint by renaming fsimage.ckpt to fsimage. If the rename and the retry (after deleting the destination) both fail, this IOException aborts startup. Same environmental causes: permissions, cross-device rename semantics, or a locked destination file.","triggerScenarios":"ckptFile.renameTo(curFile) returns false twice during doRecovery() while fsimage.ckpt exists and edits.new does not — permission errors, destination held open (Windows renameTo also fails when the destination exists), or source/destination on different filesystems.","commonSituations":"current/ directory not writable by the NN user; another process (second NN, OIV) holds fsimage open; name storage split across symlinked mounts.","solutions":["Fix ownership and write permission on the whole current/ directory for the NN user","Close/unlock anything holding fsimage open; verify no second NameNode is running on the same dirs","Manually finish the recovery after confirming edits.new is absent: mv fsimage.ckpt fsimage, then restart","Keep name storage on a single filesystem; avoid symlink tricks across devices"],"exampleFix":"# before: rename fails, ckpt stranded\nls /dfs/name/current/   # fsimage.ckpt present, edits.new absent, no fsimage\n# after: complete the checkpoint by hand and restart\nmv /dfs/name/current/fsimage.ckpt /dfs/name/current/fsimage\nsu - hdfs -c 'hdfs --daemon start namenode'","handlingStrategy":"validation","validationCode":"File cur = new File(nameDir, \"current\");\nif (!Files.isWritable(cur.toPath())) throw new IOException(\"not writable: \" + cur);\n// rename round-trip check on the same filesystem\nFile probe = File.createTempFile(\"nn\", \".probe\", cur);\nif (!probe.renameTo(new File(probe.getAbsolutePath() + \".r\"))) {\n  throw new IOException(\"rename not permitted in \" + cur);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the whole current/ directory writable by the NN user","Do not split name storage across filesystems via symlinks","On Windows, exclude name dirs from antivirus scanning so renameTo is not blocked"],"tags":["hadoop","hdfs","namenode","checkpoint-recovery","file-rename","legacy-format"],"backgroundTag":"file-rename-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}