mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #6286 from bdarnell/initial-election-check-quorum
raft: Allow an election immediately after start with checkQuorum
This commit is contained in:
commit
48f4a7d037
@ -598,7 +598,7 @@ func (r *raft) Step(m pb.Message) error {
|
||||
lead := m.From
|
||||
if m.Type == pb.MsgVote {
|
||||
force := bytes.Equal(m.Context, []byte(campaignTransfer))
|
||||
inLease := r.checkQuorum && r.state != StateCandidate && r.electionElapsed < r.electionTimeout
|
||||
inLease := r.checkQuorum && r.lead != None && r.electionElapsed < r.electionTimeout
|
||||
if !force && inLease {
|
||||
// If a server receives a RequestVote request within the minimum election timeout
|
||||
// of hearing from a current leader, it does not update its term or grant its vote
|
||||
|
@ -1281,10 +1281,8 @@ func TestLeaderElectionWithCheckQuorum(t *testing.T) {
|
||||
setRandomizedElectionTimeout(a, a.electionTimeout+1)
|
||||
setRandomizedElectionTimeout(b, b.electionTimeout+2)
|
||||
|
||||
// Letting b's electionElapsed reach to timeout so that it can vote for a
|
||||
for i := 0; i < b.electionTimeout; i++ {
|
||||
b.tick()
|
||||
}
|
||||
// Immediately after creation, votes are cast regardless of the
|
||||
// election timeout.
|
||||
nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
|
||||
|
||||
if a.state != StateLeader {
|
||||
|
Loading…
x
Reference in New Issue
Block a user