-
Notifications
You must be signed in to change notification settings - Fork 398
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
Learner needs to respond vote requests. #58
Conversation
@BusyJay @Hoverbear @overvenus PTAL thanks. |
4dd5c84
to
d2c8ff5
Compare
src/raft.rs
Outdated
at term {}", | ||
self.tag, | ||
if self.is_learner { "learner" } else { "voter" }, |
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.
This is redundant.
tests/cases/test_raft.rs
Outdated
nw.peers.get_mut(&3).unwrap().tick(); | ||
} | ||
|
||
// MsgRequeestVote should only come from 1. |
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.
Too many e
s in MsgRequeestVote
@hicqu I see that in #57 (comment) a candidate check was written about. In this PR I don't see an added candidate check. Was this already implemented, or found to be unnecessary? |
@Hoverbear I omitted the check, because voters only send |
ping @BusyJay @overvenus . |
tests/cases/test_raft.rs
Outdated
}; | ||
|
||
let mut network = Network::new(vec![Some(n1), None, Some(n3)]); | ||
network.isolate(2); |
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.
None
means it won't respond to requests already.
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.
After I remove this, store 1 will be elected as leader.
tests/cases/test_raft.rs
Outdated
let do_campaign = |nw: &mut Network| { | ||
for _ in 0..timeout << 1 { | ||
nw.peers.get_mut(&1).unwrap().tick(); | ||
nw.peers.get_mut(&3).unwrap().tick(); |
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 point of ticking node 3?
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.
To show all Vote
messages come from store 1 even if 3 will also step(MsgHup)
.
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.
I don't get it. Where are all those messages showed? How does it help with the test case?
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.
Removed.
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.
No, they are still here.
tests/cases/test_raft.rs
Outdated
} | ||
|
||
// MsgRequestVote should only come from 1. | ||
let msgs = read_messages(nw.peers.get_mut(&1).unwrap()); |
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.
Why not send a MsgHup
to node 1 directly?
tests/cases/test_raft.rs
Outdated
do_campaign(&mut network); | ||
assert_eq!(network.peers[&1].state, StateRole::Candidate); | ||
|
||
match network.peers.get_mut(&1) { |
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.
unwrap
is OK.
2bdf8d9
to
faa583c
Compare
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.
LGTM
So that if some voters fail, rest voters and learners can still form a quorum. Fix #57 .