-
Notifications
You must be signed in to change notification settings - Fork 409
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
reset max_apply_unpersisted_log_limit in become_follower #561
base: master
Are you sure you want to change the base?
Conversation
@Connor1996 @overvenus @gengliqi PTAL, thanks~ |
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.
Can we add a test to cover the case?
Signed-off-by: glorv <[email protected]>
4247a6a
to
09742ec
Compare
Signed-off-by: glorv <[email protected]>
943a840
to
d5a0e2c
Compare
src/raft.rs
Outdated
@@ -1152,6 +1152,12 @@ impl<T: Storage> Raft<T> { | |||
let from_role = self.state; | |||
self.state = StateRole::Follower; | |||
self.pending_request_snapshot = pending_request_snapshot; | |||
// TODO: In theory, we should better control this in the caller, |
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.
"caller" -> "user" ?
Signed-off-by: glorv <[email protected]>
@Connor1996 @hhwyt PTAL again |
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
@overvenus PTAL |
Would you mind putting down some context in the PR description? Otherwise it might not be obvious to future readers that this change is part of tikv/tikv#18241. |
Co-authored-by: Bisheng Huang <[email protected]> Signed-off-by: glorv <[email protected]>
|
||
for _ in 0..=sm.election_timeout() { | ||
sm.tick(); | ||
} | ||
|
||
assert_eq!(sm.state, StateRole::Follower); | ||
// check after become follower, the limit is reset. |
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.
Please add some comments explaining why the reset is necessary.
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.
Done. PTAL again, thanks
Signed-off-by: glorv <[email protected]>
…to reset-on-follower
This PR reset the
max_apply_unpersisted_log_limit
value when peer role demote from leader to follower. Because the user can only notice role change event after callready()
and the committed entries are collected in theready()
so we have to do this here to ensure we only enablemax_apply_unpersisted_log_limit
on raft leader.NOTE: In theory, the affect of
max_apply_unpersisted_log_limit
is not related the raft role. We limit it to only leader to prevent potencial corn cases. We may want to remove this restriction in the future. In that case, we should revert this PR then.See tikv/tikv#17868 for more details.