{"record":{"id":"a59fb45c700b1a67","repo":"apache/flink","slug":"committing-file-failed-could-not-rename","errorCode":null,"errorMessage":"Committing file failed, could not rename {} -> {}","messagePattern":"Committing file failed, could not rename (.+?) -> (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/fs/local/LocalRecoverableFsDataOutputStream.java","lineNumber":165,"sourceCode":"        @Override\n        public void commit() throws IOException {\n            final File src = recoverable.tempFile();\n            final File dest = recoverable.targetFile();\n\n            // sanity check\n            if (src.length() != recoverable.offset()) {\n                // something was done to this file since the committer was created.\n                // this is not the \"clean\" case\n                throw new IOException(\"Cannot clean commit: File has trailing junk data.\");\n            }\n\n            // rather than fall into default recovery, handle errors explicitly\n            // in order to improve error messages\n            try {\n                Files.move(src.toPath(), dest.toPath(), StandardCopyOption.ATOMIC_MOVE);\n            } catch (UnsupportedOperationException | AtomicMoveNotSupportedException e) {\n                if (!src.renameTo(dest)) {\n                    throw new IOException(\n                            \"Committing file failed, could not rename \" + src + \" -> \" + dest);\n                }\n            } catch (FileAlreadyExistsException e) {\n                throw new IOException(\n                        \"Committing file failed. Target file already exists: \" + dest);\n            }\n        }\n\n        @Override\n        public void commitAfterRecovery() throws IOException {\n            final File src = recoverable.tempFile();\n            final File dest = recoverable.targetFile();\n            final long expectedLength = recoverable.offset();\n\n            if (src.exists()) {\n                if (src.length() > expectedLength) {\n                    // can happen if we co from persist to recovering for commit directly\n                    // truncate the trailing junk away","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalRecoverableFsDataOutputStream.java#L147-L183","documentation":"Thrown by LocalRecoverableFsDataOutputStream.commit() when the atomic move (Files.move with ATOMIC_MOVE) is not supported and the fallback java.io.File.renameTo also fails. The rename from temp to target could not be completed.","triggerScenarios":"Commit() on a filesystem/OS where ATOMIC_MOVE is unsupported (catches UnsupportedOperationException/AtomicMoveNotSupportedException), and the fallback renameTo(dest) returns false.","commonSituations":"Cross-device rename (temp and target on different mount points); permissions on the target directory; target path locked/open on Windows; filesystem that disallows rename.","solutions":["Ensure temp file and target file reside on the same filesystem/volume.","Fix permissions on the target directory for the Flink user.","Close any handles on the target file (especially on Windows) before commit.","If cross-volume is unavoidable, reconfigure temp dir to share the target's volume."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"void ensureSameVolume(File src, File dest) throws IOException {\n    if (!src.toPath().getParent().equals(dest.toPath().getParent())\n        && !src.getAbsolutePath().startsWith(rootsOf(dest)))\n        throw new IOException(\"temp and target likely on different volumes\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    committer.commit();\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Committing file failed, could not rename\")) {\n        // move temp to same volume as target, or fix perms, then retry\n    }\n    throw e;\n}","preventionTips":["Keep temp and target on the same filesystem/volume.","Ensure the Flink user can write the target directory.","Close target file handles before commit, especially on Windows."],"tags":["filesystem","local-fs","recoverable-writer","commit","rename","cross-device"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}