Fix panic in store reader raw document iterator during segment merge #1076
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.
The store reader raw document iterator fails when the first document of a block past a new checkpoint has been deleted. This was caused by the
reset_block_pos
flag used to resetblock_start_pos
being discarded when the current document isn't alive.Depending on the state of the segments, I could triggered two different panics related to the varint deserialization in the iterator. See this. One involves a bit shifting overflow in the
Vint
deserialization itself, and one involves reading a wrong and huge doc length, leading to a out of range slice. In all cases, another thread also panics after dropping aRamDirectory
'sVecWriter
without flushing it, caused by aVInt
deserialization error inIndexMerger.write
, making the function return before closing writers.Unfortunately, this is the minimal test I could find to reproduce the issue... I would have liked a straightforward test, but it seems like a few merges, with enough data per segment, need to happen to trigger the bug. Because of that, the test is slower than what I'd consider acceptable for a unit test (~10s on my machine).
Let me know what you want to do about the test, or if you have a better idea to test the issue.