{"record":{"id":"fbe61ebb0c139185","repo":"apache/pulsar","slug":"invalid-metavalue-format-version-version","errorCode":null,"errorMessage":"Invalid MetaValue format version=${version}","messagePattern":"Invalid MetaValue format version=(.+?)","errorType":"exception","errorClass":"MetadataStoreException","httpStatus":null,"severity":"error","filePath":"pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java","lineNumber":175,"sourceCode":"                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        }\n    }\n\n    @VisibleForTesting\n    static byte[] toBytes(String s) {\n        return s.getBytes(StandardCharsets.UTF_8);\n    }\n\n    @VisibleForTesting\n    static String toString(byte[] bytes) {\n        return new String(bytes, StandardCharsets.UTF_8);\n    }\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java#L157-L193","documentation":"MetaValue.parse reads a format version int from the value header and only accepts versions >= FORMAT_VERSION_V1. This error means the on-disk value carries an unrecognized (older or newer) serialization format, so the record cannot be safely deserialized.","triggerScenarios":"Reading a RocksDB metadata store that was written by a different version of the code with an incompatible MetaValue layout, or reading bytes whose header version field is corrupt/zero from a foreign writer.","commonSituations":"Upgrading or downgrading Pulsar across a metadata format change and pointing at the old rocksdb:// data directory; mixing store versions against one data directory.","solutions":["Use a Pulsar version whose FORMAT_VERSION_V1 matches the version that wrote the data directory.","Migrate data via a supported path (export metadata and re-import) rather than opening the old directory directly with a newer build.","Delete/rewrite the affected records if the value is disposable.","Back up the data directory before any version migration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mv = MetaValue.parse(raw);\n} catch (MetadataStoreException e) {\n    if (e.getMessage().contains(\"format version\")) {\n        // migrate with matching store version or discard record\n    } else throw e;\n}","preventionTips":["Keep the Pulsar/metadata-store version consistent with the one that wrote the data","Back up before version upgrades","Do not mix store builds against one data directory"],"tags":["rocksdb","deserialization","version-incompatibility"],"backgroundTag":"metadata-format-version-unsupported","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"}