Skip to content

MB-73970: Skip writing fileWriter trailer to index metadata when unset - #2400

Merged
capemox merged 3 commits into
masterfrom
fix/index-meta-empty-callback-id-trailer
Sep 22, 2026
Merged

capemox merged 3 commits into
masterfrom
fix/index-meta-empty-callback-id-trailer

Conversation

@capemox

@capemox capemox commented Sep 22, 2026

Copy link
Copy Markdown
Member

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.

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.
@coveralls

coveralls commented Sep 22, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 51.699% (-0.04%) from 51.74% — fix/index-meta-empty-callback-id-trailer into master

@capemox
capemox merged commit 3235617 into master Sep 22, 2026
10 checks passed
@capemox
capemox deleted the fix/index-meta-empty-callback-id-trailer branch September 22, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants