Fix: reset pos when crossing segment boundary in find_offset_in_segments#1772
Fix: reset pos when crossing segment boundary in find_offset_in_segments#1772kickster97 merged 2 commits intomainfrom
Conversation
|
Code Review: No issues found. The fix is correct. When |
viktorerlingsson
left a comment
There was a problem hiding this comment.
Oh, good catch. I've mostly tested with int offsets, and then you can never be between two segments, so that case was missed. In any other case we only ever check one segment in find_offset_in_segments, so reseting pos wasn't needed.
We should be able to eliminate that for timestamp offsets as well by using @segment_last_ts, so we don't have to scan a full segment only to move on to the next. But then we really need this as well #1760
Co-authored-by: Viktor Erlingsson <viktor@84codes.com>
|
Code Review No issues found. The fix correctly resets |
WHAT is this pull request doing?
Fixes #1771
Restores the
pos = 4u32reset infind_offset_in_segmentswhen advancing to the next segment.In #1479, the original
pos = 4_u32was changed torfile.pos = 4u32. During review it was mentioned that the method uses a localposvariable, notrfile.pos. When resolving, the line was removed entirely instead of being changed back topos = 4u32.Without the reset, when a timestamp-based
x-stream-offsetfalls between two segments, the method walks all messages in the first segment, crosses to the next segment, and reads from the old segment's end position, causing anIndexErroror potentially a SEGFAULT.HOW can this pull request be tested?
Run added spec