-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recover from last log segment with invalid messages #3018
Recover from last log segment with invalid messages #3018
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3018 +/- ##
============================================
+ Coverage 64.24% 69.95% +5.70%
- Complexity 10398 12205 +1807
============================================
Files 840 894 +54
Lines 71755 75615 +3860
Branches 8611 9035 +424
============================================
+ Hits 46099 52893 +6794
+ Misses 23004 19961 -3043
- Partials 2652 2761 +109 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just left one question.
*/ | ||
void truncateTo(long offset) throws IOException { | ||
long currentFileSize = sizeInBytes(); | ||
if (currentFileSize < offset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QQ: in which scenario this will happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should never happen, adding it here just for sanity check.
Summary
Since we don't ignore invalid log segment from this PR #2744, we run into lots of error replicas due to invalid messages in last log segment when power outage happens. This PR adds configuration and logic to deal with those errors.
When there are invalid messages in the log segment when persistent index is trying to recover index segment files, we check if the log segment is the last log segment and if the amount of remaining bytes are small, if so, we just ignore the invalid message and move on with the valid message.
Testing Done
Added unit tests.