Repository navigation
[server] Fix TabletServer fails to restart after unclean shutdown due to EOFException in log recovery - #2942
Conversation
65ef17f to
51fa15a
Compare
There was a problem hiding this comment.
@LiebingYu Thanks for the PR, we bumped into this issue last week, so I studied this code
The unconditional-recoverSegment change is right (matches Kafka), but the fix doesn't actually close this issue in my opinion.
I was able to reproduced the crash by appending 40 zero bytes to the active .log (typical shape after an interrupted write). The crash is inside recover() itself: it asks for max-timestamp before doing anything, the getter scans the whole file to compute it, and the scan walks into the corrupt tail.
The possible fix might be small: track max-timestamp in a local variable inside the loop instead of going through the getter. Recovery is iterating every batch anyway.
The new test passes against the buggy code: its garbage bytes happen to decode as a huge length, so the iterator rejects the would-be batch before reaching the bug. If we switch the bytes to zeros, then it fails on this branch.
Three smaller things I noticed in the same area, all pre-existing:
- recover()'s catch is for CorruptRecordException, but it can also fail with CRC check with CorruptMessageException, for example
- an unrecognised magic byte throws an uncaught IllegalArgumentException from the parser, and we had it during our unclean shutdown when garbage was interpreted this way
|
Thanks @fresh-borzoni for the review comments. Your finding sounds make sense to me. I think we should address them as well. What do you think @LiebingYu @swuferhong ? |
… to EOFException in log recovery
51fa15a to
51371eb
Compare
|
@fresh-borzoni Thank you for your insightful discovery. The new test does exactly bypass the batch parsing, and has been modified to use 40 zero bytes. On this issue, the core differences between Fluss and Kafka are:
All of these have been handled. Could you please help review it again? Feel free to let me know if you have any concerns. |
wuchong
left a comment
There was a problem hiding this comment.
LGTM.
@fresh-borzoni @swuferhong could you take another look?
Purpose
Linked issue: close #2941
Brief change log
Tests
API and Format
Documentation