{"record":{"id":"2964861cdc3bfc06","repo":"apache/druid","slug":"invalid-frame-file-trailer-for-object","errorCode":null,"errorMessage":"Invalid frame file trailer for object : ","messagePattern":"Invalid frame file trailer for object : ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"multi-stage-query/src/main/java/org/apache/druid/msq/shuffle/output/DurableStorageTaskOutputChannelFactory.java","lineNumber":184,"sourceCode":"        );\n\n    final Supplier<Long> channelSizeSupplier = countingOutputStream::getCount;\n\n    final File footerFile = new File(tmpDir, fileName + \"_footer\");\n    // build supplier for reading the footer of the underlying frame file\n    final Supplier<FrameFileFooter> frameFileFooterSupplier = Suppliers.memoize(() -> {\n      try {\n        // read trailer and find the footer size\n        byte[] trailerBytes = new byte[FrameFileWriter.TRAILER_LENGTH];\n        long channelSize = channelSizeSupplier.get();\n        try (InputStream reader = storageConnector.readRange(\n            fileName,\n            channelSize - FrameFileWriter.TRAILER_LENGTH,\n            FrameFileWriter.TRAILER_LENGTH\n        )) {\n          int bytesRead = reader.read(trailerBytes, 0, trailerBytes.length);\n          if (bytesRead != FrameFileWriter.TRAILER_LENGTH) {\n            throw new RuntimeException(\"Invalid frame file trailer for object : \" + fileName);\n          }\n        }\n\n        Memory trailer = Memory.wrap(trailerBytes);\n        int footerLength = trailer.getInt(Integer.BYTES * 2L);\n\n        // read the footer into a file and map it to memory\n        FileUtils.mkdirp(footerFile.getParentFile());\n        Preconditions.checkState(footerFile.createNewFile(), \"Unable to create local footer file\");\n        try (FileOutputStream footerFileStream = new FileOutputStream(footerFile);\n             InputStream footerInputStream =\n                 storageConnector.readRange(fileName, channelSize - footerLength, footerLength)) {\n          IOUtils.copy(footerInputStream, footerFileStream);\n        }\n        MappedByteBufferHandler mapHandle = FileUtils.map(footerFile);\n        Memory footerMemory = Memory.wrap(mapHandle.get(), ByteOrder.LITTLE_ENDIAN);\n\n        // create a frame file footer from the mapper memory","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/multi-stage-query/src/main/java/org/apache/druid/msq/shuffle/output/DurableStorageTaskOutputChannelFactory.java#L166-L202","documentation":"openPartitionedChannel validates each written frame file by reading its trailer (the last FrameFileWriter.TRAILER_LENGTH bytes) and throws a RuntimeException when the trailer bytes read is shorter than the expected trailer length. This means the frame file is truncated or corrupt and its metadata (frame sizes/counts) cannot be parsed.","triggerScenarios":"Reading the trailer of the partition output file via FileChannel.read returns fewer bytes than TRAILER_LENGTH: the file was written incompletely (producer crash/disk full), uploaded partially to deep storage, or is otherwise truncated/corrupt.","commonSituations":"Worker killed (OOM/preemption) while writing output; interrupted upload leaving a partial object; disk full on the task's tmp dir; version mismatch causing wrong trailer format expectations.","solutions":["Rerun the query so the producer rewrites the partition output file.","Check the producing task logs for crash/disk-full errors and verify the file size in deep storage against the expected channel size.","Check task-runner reliability (avoid killing tasks mid-write) and deep-storage upload integrity (multipart completion).","Verify all Druid services run compatible MSQ versions to avoid format mismatches."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// sanity-check remote object size before parsing the trailer\nlong size = storageConnector.size(fileName);\nif (size <= FrameFileWriter.TRAILER_LENGTH) {\n  throw new IllegalStateException(\"Frame file suspiciously small/truncated: \" + fileName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  readPartitionOutput();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Invalid frame file trailer\")) {\n    rerunQuery(); // truncated output must be regenerated\n  } else { throw e; }\n}","preventionTips":["Ensure task workers are not OOM-killed or preempted mid-write.","Monitor task disks for full-disk conditions during large shuffles.","Keep MSQ engine versions uniform across the cluster."],"tags":["msq","corruption","frame-file","truncated-file"],"backgroundTag":"checksum-mismatch","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}