-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Raft] refactor processAppendLogRequest #3435
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3435 +/- ##
========================================
Coverage 85.19% 85.19%
========================================
Files 1304 1305 +1
Lines 121308 121417 +109
========================================
+ Hits 103352 103445 +93
- Misses 17956 17972 +16
Continue to review full report at Codecov.
|
cf1c660
to
444daea
Compare
Ready to review |
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
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.
What's the general rule of setting rpc timeout?
Use the same raft rpc timeout is ok, previously there is a bug, so election use an another timeout. |
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
Change notes:
Main change is in
processAppendLogRequest
A brief flow as follows (not exactly same in code):
To achieve this goal, some others need to be modified:
committedLogId
andcommittedLogTerm
in resp. But committedLogTerm is missing previously, so I add one.We need to make sure
lastLogId_ == wal_->lastLogId()
in almost every case (except leader is replicating), we did this by callingwal_->rollbackToLog
, since we handleAppendLog
correctly, we don't need to rollback anymore, just setlastLogId_ = wal_->lastLogId()
is enough.All request and resp should carry the term, step down as follower when a higher term found, otherwise we may failed to elect a leader.
micor changes: make
RaftPart::cleanup
atomic