{"record":{"id":"dd9c4f3ca5ae37df","repo":"apache/pulsar","slug":"invalid-metavalue-data-no-enough-header-data-exp","errorCode":null,"errorMessage":"Invalid MetaValue data, no enough header data. expect %d, actual %d","messagePattern":"Invalid MetaValue data, no enough header data\\. expect (.+?), actual (.+?)","errorType":"exception","errorClass":"MetadataStoreException","httpStatus":null,"severity":"error","filePath":"pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java","lineNumber":163,"sourceCode":"            buffer.putLong(createdTimestamp);\n            buffer.putLong(modifiedTimestamp);\n            buffer.put((byte) (ephemeral ? 1 : 0));\n            buffer.put(data);\n            return result;\n        }\n\n        public static MetaValue parse(byte[] dataBytes) throws MetadataStoreException {\n            if (dataBytes == null) {\n                return null;\n            }\n            if (dataBytes.length < 4) {\n                throw new MetadataStoreException(\"Invalid MetaValue data, size=\" + dataBytes.length);\n            }\n            ByteBuffer buffer = ByteBuffer.wrap(dataBytes);\n            MetaValue metaValue = new MetaValue();\n            int headerSize = buffer.getInt();\n            if (dataBytes.length < headerSize) {\n                throw new MetadataStoreException(\n                        String.format(\"Invalid MetaValue data, no enough header data. expect %d, actual %d\",\n                                headerSize, dataBytes.length));\n            }\n            int formatVersion = buffer.getInt();\n            if (formatVersion >= FORMAT_VERSION_V1) {\n                metaValue.version = buffer.getLong();\n                metaValue.owner = buffer.getLong();\n                metaValue.createdTimestamp = buffer.getLong();\n                metaValue.modifiedTimestamp = buffer.getLong();\n                metaValue.ephemeral = buffer.get() > 0;\n            } else {\n                throw new MetadataStoreException(\"Invalid MetaValue format version=\" + formatVersion);\n            }\n            buffer.position(headerSize);\n            metaValue.data = new byte[buffer.remaining()];\n            buffer.get(metaValue.data);\n            return metaValue;\n        }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java#L145-L181","documentation":"MetaValue.parse deserializes the RocksDB-stored value blob, which begins with a header: an int headerSize, a format version int, and metadata fields. This error means the stored byte array is shorter than the declared header size, so the header cannot be read fully. The library throws it to guard against corrupt, truncated, or non-MetaValue data stored under a path.","triggerScenarios":"Calling storeGet/storeDelete/storePut on a RocksdbMetadataStore path whose raw value bytes were written by another tool, hand-corrupted in RocksDB, or truncated on disk, such that dataBytes.length < the headerSize int at offset 0.","commonSituations":"RocksDB data directory copied or restored partially from backup; a different application sharing the same data directory wrote its own bytes; disk corruption; manually editing values in the DB.","solutions":["Inspect the offending path's raw value in RocksDB and delete it so it can be rewritten (e.g. via a rocksdb tool or the store delete API bypassing parse).","Verify the data directory is not shared with, or populated by, another application or an older incompatible data layout.","Restore the RocksDB data directory from a known-good backup.","If corruption is widespread, wipe the metadata store and re-create metadata (recovery from source systems)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"static boolean looksLikeMetaValue(byte[] data) {\n    if (data == null || data.length < 8) return false;\n    int headerSize = ByteBuffer.wrap(data).getInt();\n    return headerSize > 0 && headerSize <= data.length;\n}","typeGuard":"static boolean isParseable(byte[] data) {\n    try { MetaValue.parse(data); return true; } catch (MetadataStoreException e) { return false; }\n}","tryCatchPattern":"try {\n    MetaValue mv = MetaValue.parse(raw);\n} catch (MetadataStoreException e) {\n    log.warn(\"Corrupt metadata value, will recreate\", e);\n    // delete and rewrite the record\n}","preventionTips":["Never share a rocksdb:// data directory between applications","Back up the directory with RocksDB-consistent checkpoints, not raw file copies","Monitor disk health; corruption is usually hardware/IO induced"],"tags":["rocksdb","deserialization","data-corruption"],"backgroundTag":"metadata-store-corrupt-value","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}