index: fix repeated v2 index merge panic#101
Open
idrassi wants to merge 1 commit intogoogle:masterfrom
Open
Conversation
Repeated merges of v2 indexes could treat the on-disk posting-list sentinel, invalidTrigram (0x00ffffff), as a normal trigram because the merge reader used ^uint32(0) as its internal EOF marker. That let duplicate serialized sentinels accumulate in the posting index, and a later cindex run could panic with no progress while merging. Use invalidTrigram consistently in postMapReader and merge sentinel handling. Restore lazy posting-list writes so ordinary trigrams with no surviving file IDs are omitted while the final sentinel is still emitted. Add a repeated-merge regression test that checks merged v2 indexes stay valid and do not grow extra posting entries. Fixes google#100.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Fixes #100.
Repeated cindex runs against a v2 index could panic during merge with:
The merge reader used ^uint32(0) as its internal EOF marker, while the on-disk posting-list sentinel is invalidTrigram (0x00ffffff). As a result, merge treated the serialized sentinel as a normal trigram and then emitted another sentinel at EOF. Each successful merge accumulated another serialized sentinel and a later merge could stop making progress through the duplicate sentinel entries.
This change makes merge sentinel handling use invalidTrigram consistently. It also restores lazy posting-list writes so ordinary trigrams with no surviving file IDs are omitted, while the final sentinel is still emitted.
A regression test now repeatedly merges v2 indexes and checks that the merged index remains valid and does not grow extra posting entries.
Testing:
go test ./...I also verified the issue reproduction manually on linux/amd64 with repeated no-argument cindex runs. The patched binary completed repeated reindexes, cindex-check -list passed and the final posting index contained exactly one 0xffffff sentinel with no non-increasing trigram entries.