diff --git a/testdata/vote.txt b/testdata/vote.txt index 80e1cf84..5c2e70a8 100644 --- a/testdata/vote.txt +++ b/testdata/vote.txt @@ -1,10 +1,11 @@ -# Tests that a node that is behind on the log will lose the vote. +# Tests that a node that is behind on the log will lose the vote. Other nodes +# will have higher priority to start next campaign within current term. log-level none ---- ok -add-nodes 2 voters=(1,2) index=10 +add-nodes 2 voters=(1,2) index=10 heartbeat-tick=1 election-tick=5 ---- ok @@ -95,3 +96,120 @@ raft-log 1 raft-log 2 ---- 1/11 EntryNormal "" + +# 2 is de-prioritized on the next campaign. Its randomized election timeout +# is in range [2*electionTime, 3*electionTime), namely [10, 15). So 9 ticks +# shouldn't trigger the campaign. +tick 2 9 +---- +ok + +raft-state +---- +1: StateFollower (Voter) Term:2 Lead:0 +2: StateFollower (Voter) Term:2 Lead:0 + +# 1's randomized election timeout doesn't change, it's still in range +# [electionTime, 2*electionTime), namely [5, 10). So 9 ticks will definitely +# trigger the campaign. +tick 1 9 +---- +INFO 1 is starting a new election at term 2 +INFO 1 became candidate at term 3 +INFO 1 [logterm: 1, index: 12] sent MsgVote request to 2 at term 3 + +raft-state +---- +1: StateCandidate (Voter) Term:3 Lead:0 +2: StateFollower (Voter) Term:2 Lead:0 + +stabilize +---- +> 1 handling Ready + Ready MustSync=true: + Lead:0 State:StateCandidate + HardState Term:3 Vote:1 Commit:11 + Messages: + 1->2 MsgVote Term:3 Log:1/12 + INFO 1 received MsgVoteResp from 1 at term 3 + INFO 1 has received 1 MsgVoteResp votes and 0 vote rejections +> 2 receiving messages + 1->2 MsgVote Term:3 Log:1/12 + INFO 2 [term: 2] received a MsgVote message with higher term from 1 [term: 3] + INFO 2 became follower at term 3 + INFO 2 [logterm: 1, index: 11, vote: 0] cast MsgVote for 1 [logterm: 1, index: 12] at term 3 +> 2 handling Ready + Ready MustSync=true: + HardState Term:3 Vote:1 Commit:11 + Messages: + 2->1 MsgVoteResp Term:3 Log:0/0 +> 1 receiving messages + 2->1 MsgVoteResp Term:3 Log:0/0 + INFO 1 received MsgVoteResp from 2 at term 3 + INFO 1 has received 2 MsgVoteResp votes and 0 vote rejections + INFO 1 became leader at term 3 +> 1 handling Ready + Ready MustSync=true: + Lead:1 State:StateLeader + Entries: + 3/13 EntryNormal "" + Messages: + 1->2 MsgApp Term:3 Log:1/12 Commit:11 Entries:[3/13 EntryNormal ""] +> 2 receiving messages + 1->2 MsgApp Term:3 Log:1/12 Commit:11 Entries:[3/13 EntryNormal ""] + DEBUG 2 [logterm: 0, index: 12] rejected MsgApp [logterm: 1, index: 12] from 1 +> 2 handling Ready + Ready MustSync=false: + Lead:1 State:StateFollower + Messages: + 2->1 MsgAppResp Term:3 Log:1/12 Rejected (Hint: 11) +> 1 receiving messages + 2->1 MsgAppResp Term:3 Log:1/12 Rejected (Hint: 11) + DEBUG 1 received MsgAppResp(rejected, hint: (index 11, term 1)) from 2 for index 12 + DEBUG 1 decreased progress of 2 to [StateProbe match=0 next=12] +> 1 handling Ready + Ready MustSync=false: + Messages: + 1->2 MsgApp Term:3 Log:1/11 Commit:11 Entries:[ + 1/12 EntryNormal "foo" + 3/13 EntryNormal "" + ] +> 2 receiving messages + 1->2 MsgApp Term:3 Log:1/11 Commit:11 Entries:[ + 1/12 EntryNormal "foo" + 3/13 EntryNormal "" + ] +> 2 handling Ready + Ready MustSync=true: + Entries: + 1/12 EntryNormal "foo" + 3/13 EntryNormal "" + Messages: + 2->1 MsgAppResp Term:3 Log:0/13 +> 1 receiving messages + 2->1 MsgAppResp Term:3 Log:0/13 +> 1 handling Ready + Ready MustSync=false: + HardState Term:3 Vote:1 Commit:13 + CommittedEntries: + 1/12 EntryNormal "foo" + 3/13 EntryNormal "" + Messages: + 1->2 MsgApp Term:3 Log:3/13 Commit:13 +> 2 receiving messages + 1->2 MsgApp Term:3 Log:3/13 Commit:13 +> 2 handling Ready + Ready MustSync=false: + HardState Term:3 Vote:1 Commit:13 + CommittedEntries: + 1/12 EntryNormal "foo" + 3/13 EntryNormal "" + Messages: + 2->1 MsgAppResp Term:3 Log:0/13 +> 1 receiving messages + 2->1 MsgAppResp Term:3 Log:0/13 + +raft-state +---- +1: StateLeader (Voter) Term:3 Lead:1 +2: StateFollower (Voter) Term:3 Lead:1