{"record":{"id":"07531f98dfa6d87e","repo":"apache/pulsar","slug":"data-block-header-magic-word-not-match-read-ma-07531f","errorCode":null,"errorMessage":"Data block header magic word not match. read: ${magic} expected: ${MAGIC_WORD}","messagePattern":"Data block header magic word not match\\. read: (.+?) expected: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/StreamingDataBlockHeaderImpl.java","lineNumber":98,"sourceCode":"    @Override\n    public long getFirstEntryId() {\n        return this.firstEntryId;\n    }\n\n    public StreamingDataBlockHeaderImpl(long headerLength, long blockLength, long ledgerId, long firstEntryId) {\n        this.headerLength = headerLength;\n        this.blockLength = blockLength;\n        this.firstEntryId = firstEntryId;\n        this.ledgerId = ledgerId;\n    }\n\n    // Construct DataBlockHeader from InputStream, which contains `HEADER_MAX_SIZE` bytes readable.\n    public static StreamingDataBlockHeaderImpl fromStream(InputStream stream) throws IOException {\n        CountingInputStream countingStream = new CountingInputStream(stream);\n        DataInputStream dis = new DataInputStream(countingStream);\n        int magic = dis.readInt();\n        if (magic != MAGIC_WORD) {\n            throw new IOException(\"Data block header magic word not match. read: \" + magic\n                    + \" expected: \" + MAGIC_WORD);\n        }\n\n        long headerLen = dis.readLong();\n        long blockLen = dis.readLong();\n        long firstEntryId = dis.readLong();\n        long ledgerId = dis.readLong();\n        long toSkip = headerLen - countingStream.getCount();\n        if (dis.skip(toSkip) != toSkip) {\n            throw new EOFException(\"Header was too small\");\n        }\n\n        return new StreamingDataBlockHeaderImpl(headerLen, blockLen, ledgerId, firstEntryId);\n    }\n\n    /**\n     * Get the content of the data block header as InputStream.\n     * Read out in format:","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/StreamingDataBlockHeaderImpl.java#L80-L116","documentation":"StreamingDataBlockHeaderImpl.fromStream read a 4-byte magic word that does not match the expected offload data-block magic; the stream does not start with a valid tiered-storage block header (corrupt or misaligned data).","triggerScenarios":"Thrown at tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/StreamingDataBlockHeaderImpl.java:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the offloaded data block integrity and offset alignment","Re-offload the data if the ledger was corrupted"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}