Skip to content

Commit

Permalink
Update the test vote.txt to demo the node being de-priotized on next …
Browse files Browse the repository at this point in the history
…campaign

When a node lost the vote, it will be de-prioritized on the next campaign.
Its randomized election timeout is in range [2*electionTime, 3*electionTime).

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Feb 28, 2024
1 parent 501f717 commit 702e99a
Showing 1 changed file with 120 additions and 2 deletions.
122 changes: 120 additions & 2 deletions testdata/vote.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

0 comments on commit 702e99a

Please sign in to comment.