{"record":{"id":"cd2ce26921d16d79","repo":"apache/druid","slug":"failed-to-rename-s-to-s","errorCode":null,"errorMessage":"Failed to rename [%s] to [%s]","messagePattern":"Failed to rename \\[(.+?)\\] to \\[(.+?)\\]","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java","lineNumber":117,"sourceCode":"  }\n\n  private DataSegment pushZip(final File inDir, final File outDir, final DataSegment baseSegment) throws IOException\n  {\n    final File tmpSegmentDir = new File(config.getStorageDirectory(), makeIntermediateDir());\n    final File tmpIndexFile = new File(tmpSegmentDir, INDEX_ZIP_FILENAME);\n\n    log.debug(\"Creating intermediate directory[%s] for segment[%s].\", tmpSegmentDir.toString(), baseSegment.getId());\n    FileUtils.mkdirp(tmpSegmentDir);\n\n    try {\n      log.debug(\"Compressing files from[%s] to [%s]\", inDir, tmpIndexFile);\n      final long size = CompressionUtils.zip(inDir, tmpIndexFile, true);\n\n      FileUtils.mkdirp(outDir);\n      final File indexFileTarget = new File(outDir, tmpIndexFile.getName());\n\n      if (!tmpIndexFile.renameTo(indexFileTarget)) {\n        throw new IOE(\"Failed to rename [%s] to [%s]\", tmpIndexFile, indexFileTarget);\n      }\n\n      return baseSegment.withLoadSpec(makeLoadSpec(new File(outDir, INDEX_ZIP_FILENAME).toURI()))\n                        .withSize(size);\n    }\n    finally {\n      FileUtils.deleteDirectory(tmpSegmentDir);\n    }\n  }\n\n  private DataSegment pushNoZip(final File inDir, final File outDir, final DataSegment baseSegment) throws IOException\n  {\n    final File tmpSegmentDir = new File(config.getStorageDirectory(), makeIntermediateDir());\n    FileUtils.mkdirp(tmpSegmentDir);\n\n    try {\n      final File[] files = inDir.listFiles();\n      if (files == null) {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java#L99-L135","documentation":"LocalDataSegmentPusher.pushZip throws IOException when File.renameTo fails to move the freshly created temporary index.zip into its final location under the output directory. Java renameTo fails silently (returns false) on cross-filesystem moves or when the target exists/is locked, and the pusher surfaces that as this error.","triggerScenarios":"pushToPath -> pushZip: after CompressionUtils.zip, tmpIndexFile.renameTo(indexFileTarget) returns false, typically because temp dir and storage dir are on different mount points/filesystems.","commonSituations":"druid.segment.pusher.local.baseDir on a different volume from java.io.tmpdir; target file already exists with different ownership; NFS/storage dir permissions changed; disk-full preventing directory entry creation.","solutions":["Put the local base storage directory on the same filesystem as the temp directory (or point java.io.tmpdir at the same volume).","Check write permission on the output directory for the Druid process user.","Check for a stale target file at indexFileTarget and remove it.","Free disk space / check filesystem errors (dmesg) on the target volume."],"exampleFix":"// before: storage on data volume, tmp on root volume -> cross-device rename fails\n# druid.segment.pusher.local.baseDir=/data/druid/segments\n// after: same filesystem\n# druid.segment.pusher.local.baseDir=/data/tmp/../druid/segments  (same mount as java.io.tmpdir=/data/tmp)","handlingStrategy":"try-catch","validationCode":"File outDir = new File(baseDir, interPath);\nFileUtils.mkdirp(outDir);\nif (!outDir.canWrite()) throw new IllegalStateException(\"storage dir not writable: \" + outDir);\n// also ensure same filesystem as java.io.tmpdir:\nif (!outDir.getCanonicalPath().split(\"/\")[1].equals(System.getProperty(\"java.io.tmpdir\").split(\"/\")[1])) {\n  log.warn(\"tmp and storage dirs may be on different filesystems; renameTo may fail\");\n}","typeGuard":"boolean sameFilesystem(File a, File b) throws IOException {\n  return a.getCanonicalFile().toPath().getRoot().equals(b.getCanonicalFile().toPath().getRoot());\n}","tryCatchPattern":"try {\n  pusher.push(segment, outDir, true);\n} catch (IOException e) {\n  log.error(e, \"segment push failed (rename); check tmp/storage filesystem layout\");\n  throw e;\n}","preventionTips":["Put java.io.tmpdir and the local base storage dir on the same filesystem/mount.","Ensure the Druid process user owns write access to the storage directory.","Clean stale segment files at target paths before re-push.","Monitor disk space on the deep-storage volume."],"tags":["segment-push","io","file-rename","local-deep-storage"],"backgroundTag":"file-write-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}