MB-73970: Skip writing fileWriter trailer to index metadata when unset - #2400
Merged
Merged
Conversation
Save() and UpdateWriter() unconditionally appended the file callback id plus its 4-byte length to index_meta.json, even when no callback (e.g. encryption/compression hook) was registered - in that case Id() is "" and the append still writes a 4-byte zero-length trailer after the JSON body. That trailer breaks any older bleve reader that predates this callback mechanism: openIndexMeta() there does a single strict json.Unmarshal with no fallback, so trailing bytes after the closing '}' make it fail with ErrorIndexMetaCorrupt - even though the index itself is fine and never used a callback. This surfaced as a hard failure when a pindex's on-disk files were copied (e.g. via cbgt's file-transfer-based rebalance) from a node running this bleve version to a node running an older one. Only emit the trailer when fileWriter.Id() is non-empty, i.e. when a callback is actually in use, keeping the no-callback case byte-for-byte identical to the pre-existing index_meta.json format.
capemox
requested review from
Likith101,
Samsonnyyeet,
Thejas-bhat,
maneuvertomars and
steveyen
September 22, 2026 08:58
Likith101
approved these changes
Sep 22, 2026
Samsonnyyeet
approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Save() and UpdateWriter() unconditionally appended the file callback id plus its 4-byte length to index_meta.json, even when no callback was registered - in that case Id() is "" and the append still writes a 4-byte zero-length trailer after the JSON body.
That trailer breaks any older bleve reader that predates this callback mechanism: openIndexMeta() there does a single strict json.Unmarshal with no fallback, so trailing bytes after the closing '}' make it fail with ErrorIndexMetaCorrupt - even though the index itself is fine and never used a callback. This surfaced as a hard failure when a pindex's on-disk files were copied (e.g. via cbgt's file-transfer-based rebalance) from a node running this bleve version to a node running an older one.
Only emit the trailer when fileWriter.Id() is non-empty, i.e. when a callback is actually in use, keeping the no-callback case byte-for-byte identical to the pre-existing index_meta.json format.