# Basic tests that hook into leader de-fortification.

log-level debug
----
ok

add-nodes 3 voters=(1,2,3) index=2 async-storage-writes=true
----
INFO 1 switched to configuration voters=(1 2 3)
INFO 1 became follower at term 0
DEBUG 1 reset election elapsed to 0
INFO newRaft 1 [peers: [1,2,3], term: 0, commit: 2, applied: 2, lastindex: 2, lastterm: 1]
INFO 2 switched to configuration voters=(1 2 3)
INFO 2 became follower at term 0
DEBUG 2 reset election elapsed to 0
INFO newRaft 2 [peers: [1,2,3], term: 0, commit: 2, applied: 2, lastindex: 2, lastterm: 1]
INFO 3 switched to configuration voters=(1 2 3)
INFO 3 became follower at term 0
DEBUG 3 reset election elapsed to 0
INFO newRaft 3 [peers: [1,2,3], term: 0, commit: 2, applied: 2, lastindex: 2, lastterm: 1]

bump-epoch 1
----
  1 2 3
1 2 1 1
2 2 1 1
3 2 1 1

withdraw-support 1 1
----
  1 2 3
1 x 1 1
2 2 1 1
3 2 1 1

grant-support 1 1
----
  1 2 3
1 3 1 1
2 2 1 1
3 2 1 1

withdraw-support 2 1
----
  1 2 3
1 3 1 1
2 x 1 1
3 2 1 1

withdraw-support 3 1
----
  1 2 3
1 3 1 1
2 x 1 1
3 x 1 1

grant-support 2 1
----
  1 2 3
1 3 1 1
2 3 1 1
3 x 1 1

campaign 1
----
INFO 1 is starting a new election at term 0
INFO 1 became candidate at term 1
INFO 1 [logterm: 1, index: 2] sent MsgVote request to 2 at term 1
INFO 1 [logterm: 1, index: 2] sent MsgVote request to 3 at term 1

stabilize
----
> 1 handling Ready
  Ready MustSync=true:
  State:StateCandidate
  HardState Term:1 Vote:1 Commit:2 Lead:0 LeadEpoch:0
  Messages:
  1->2 MsgVote Term:1 Log:1/2
  1->3 MsgVote Term:1 Log:1/2
  1->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:2 Vote:1 Responses:[
    1->1 MsgVoteResp Term:1 Log:0/0
  ]
> 2 receiving messages
  1->2 MsgVote Term:1 Log:1/2
  INFO 2 [term: 0] received a MsgVote message with higher term from 1 [term: 1], advancing term
  INFO 2 became follower at term 1
  DEBUG 2 reset election elapsed to 0
  INFO 2 [logterm: 1, index: 2, vote: 0] cast MsgVote for 1 [logterm: 1, index: 2] at term 1
> 3 receiving messages
  1->3 MsgVote Term:1 Log:1/2
  INFO 3 [term: 0] received a MsgVote message with higher term from 1 [term: 1], advancing term
  INFO 3 became follower at term 1
  DEBUG 3 reset election elapsed to 0
  INFO 3 [logterm: 1, index: 2, vote: 0] cast MsgVote for 1 [logterm: 1, index: 2] at term 1
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:2 Vote:1
  Responses:
  1->1 MsgVoteResp Term:1 Log:0/0
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:2 Lead:0 LeadEpoch:0
  Messages:
  2->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:2 Vote:1 Responses:[
    2->1 MsgVoteResp Term:1 Log:0/0
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:2 Lead:0 LeadEpoch:0
  Messages:
  3->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:2 Vote:1 Responses:[
    3->1 MsgVoteResp Term:1 Log:0/0
  ]
> 1 receiving messages
  1->1 MsgVoteResp Term:1 Log:0/0
  INFO 1 received MsgVoteResp from 1 at term 1
  INFO 1 has received 1 MsgVoteResp votes and 0 vote rejections
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:2 Vote:1
  Responses:
  2->1 MsgVoteResp Term:1 Log:0/0
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:2 Vote:1
  Responses:
  3->1 MsgVoteResp Term:1 Log:0/0
> 1 receiving messages
  2->1 MsgVoteResp Term:1 Log:0/0
  INFO 1 received MsgVoteResp from 2 at term 1
  INFO 1 has received 2 MsgVoteResp votes and 0 vote rejections
  INFO 1 became leader at term 1
  3->1 MsgVoteResp Term:1 Log:0/0
> 1 handling Ready
  Ready MustSync=true:
  State:StateLeader
  HardState Term:1 Vote:1 Commit:2 Lead:1 LeadEpoch:3
  Entries:
  1/3 EntryNormal ""
  Messages:
  1->2 MsgFortifyLeader Term:1 Log:0/0
  1->2 MsgApp Term:1 Log:1/2 Commit:2 Entries:[1/3 EntryNormal ""]
  1->3 MsgApp Term:1 Log:1/2 Commit:2 Entries:[1/3 EntryNormal ""]
  1->AppendThread MsgStorageAppend Term:1 Log:1/3 Commit:2 Vote:1 Lead:1 LeadEpoch:3 Entries:[1/3 EntryNormal ""] Responses:[
    1->1 MsgAppResp Term:1 Log:0/3 Commit:2
    1->1 MsgFortifyLeaderResp Term:1 Log:0/0 LeadEpoch:3
    AppendThread->1 MsgStorageAppendResp Term:0 Log:1/3
  ]
> 2 receiving messages
  1->2 MsgFortifyLeader Term:1 Log:0/0
  1->2 MsgApp Term:1 Log:1/2 Commit:2 Entries:[1/3 EntryNormal ""]
> 3 receiving messages
  1->3 MsgApp Term:1 Log:1/2 Commit:2 Entries:[1/3 EntryNormal ""]
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:1 Log:1/3 Commit:2 Vote:1 Lead:1 LeadEpoch:3 Entries:[1/3 EntryNormal ""]
  Responses:
  1->1 MsgAppResp Term:1 Log:0/3 Commit:2
  1->1 MsgFortifyLeaderResp Term:1 Log:0/0 LeadEpoch:3
  AppendThread->1 MsgStorageAppendResp Term:0 Log:1/3
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:2 Lead:1 LeadEpoch:3
  Entries:
  1/3 EntryNormal ""
  Messages:
  2->AppendThread MsgStorageAppend Term:1 Log:1/3 Commit:2 Vote:1 Lead:1 LeadEpoch:3 Entries:[1/3 EntryNormal ""] Responses:[
    2->1 MsgFortifyLeaderResp Term:1 Log:0/0 LeadEpoch:3
    2->1 MsgAppResp Term:1 Log:0/3 Commit:2
    AppendThread->2 MsgStorageAppendResp Term:0 Log:1/3
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:2 Lead:1 LeadEpoch:0
  Entries:
  1/3 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:1 Log:1/3 Commit:2 Vote:1 Lead:1 Entries:[1/3 EntryNormal ""] Responses:[
    3->1 MsgAppResp Term:1 Log:0/3 Commit:2
    AppendThread->3 MsgStorageAppendResp Term:0 Log:1/3
  ]
> 1 receiving messages
  1->1 MsgAppResp Term:1 Log:0/3 Commit:2
  1->1 MsgFortifyLeaderResp Term:1 Log:0/0 LeadEpoch:3
  AppendThread->1 MsgStorageAppendResp Term:0 Log:1/3
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:1 Log:1/3 Commit:2 Vote:1 Lead:1 LeadEpoch:3 Entries:[1/3 EntryNormal ""]
  Responses:
  2->1 MsgFortifyLeaderResp Term:1 Log:0/0 LeadEpoch:3
  2->1 MsgAppResp Term:1 Log:0/3 Commit:2
  AppendThread->2 MsgStorageAppendResp Term:0 Log:1/3
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:1 Log:1/3 Commit:2 Vote:1 Lead:1 Entries:[1/3 EntryNormal ""]
  Responses:
  3->1 MsgAppResp Term:1 Log:0/3 Commit:2
  AppendThread->3 MsgStorageAppendResp Term:0 Log:1/3
> 1 receiving messages
  2->1 MsgFortifyLeaderResp Term:1 Log:0/0 LeadEpoch:3
  2->1 MsgAppResp Term:1 Log:0/3 Commit:2
  3->1 MsgAppResp Term:1 Log:0/3 Commit:2
> 2 receiving messages
  AppendThread->2 MsgStorageAppendResp Term:0 Log:1/3
> 3 receiving messages
  AppendThread->3 MsgStorageAppendResp Term:0 Log:1/3
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:3 Lead:1 LeadEpoch:3
  CommittedEntries:
  1/3 EntryNormal ""
  Messages:
  1->2 MsgApp Term:1 Log:1/2 Commit:2 Entries:[1/3 EntryNormal ""]
  1->2 MsgApp Term:1 Log:1/3 Commit:3
  1->3 MsgApp Term:1 Log:1/3 Commit:3
  1->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1 LeadEpoch:3
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[1/3 EntryNormal ""] Responses:[
    ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
  ]
> 2 receiving messages
  1->2 MsgApp Term:1 Log:1/2 Commit:2 Entries:[1/3 EntryNormal ""]
  1->2 MsgApp Term:1 Log:1/3 Commit:3
> 3 receiving messages
  1->3 MsgApp Term:1 Log:1/3 Commit:3
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1 LeadEpoch:3
  Responses:
> 1 processing apply thread
  Processing:
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
  Responses:
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:3 Lead:1 LeadEpoch:3
  CommittedEntries:
  1/3 EntryNormal ""
  Messages:
  2->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1 LeadEpoch:3 Responses:[
    2->1 MsgAppResp Term:1 Log:0/3 Commit:2
    2->1 MsgAppResp Term:1 Log:0/3 Commit:3
  ]
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[1/3 EntryNormal ""] Responses:[
    ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:3 Lead:1 LeadEpoch:0
  CommittedEntries:
  1/3 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1 Responses:[
    3->1 MsgAppResp Term:1 Log:0/3 Commit:3
  ]
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[1/3 EntryNormal ""] Responses:[
    ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
  ]
> 1 receiving messages
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1 LeadEpoch:3
  Responses:
  2->1 MsgAppResp Term:1 Log:0/3 Commit:2
  2->1 MsgAppResp Term:1 Log:0/3 Commit:3
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1
  Responses:
  3->1 MsgAppResp Term:1 Log:0/3 Commit:3
> 2 processing apply thread
  Processing:
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
  Responses:
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
> 3 processing apply thread
  Processing:
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
  Responses:
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
> 1 receiving messages
  2->1 MsgAppResp Term:1 Log:0/3 Commit:2
  2->1 MsgAppResp Term:1 Log:0/3 Commit:3
  3->1 MsgAppResp Term:1 Log:0/3 Commit:3
> 2 receiving messages
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]
> 3 receiving messages
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[1/3 EntryNormal ""]

print-fortification-state 1
----
1 : 3
2 : 3

step-down 1
----
DEBUG 1 setting election elapsed to start from 3 ticks after store liveness support expired
INFO 1 became follower at term 1
DEBUG 1 reset election elapsed to 0

# 3 isn't fortified by 1. However, we'll still send a MsgDeFortifyLeader to it
# because the leader can't distinguish between a follower that isn't fortifying
# it and a follower that is fortifying it but the leader hasn't heard about it
# yet.

send-de-fortify 1 3
----
ok

# De-fortifying 2 should succeed.
send-de-fortify 1 2
----
ok

stabilize
----
> 1 handling Ready
  Ready MustSync=true:
  State:StateFollower
  HardState Term:1 Vote:1 Commit:3 Lead:0 LeadEpoch:0
  Messages:
  1->3 MsgDeFortifyLeader Term:1 Log:0/0
  1->2 MsgDeFortifyLeader Term:1 Log:0/0
  1->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1
> 2 receiving messages
  1->2 MsgDeFortifyLeader Term:1 Log:0/0
  DEBUG 2 setting election elapsed to start from 3 ticks after store liveness support expired
> 3 receiving messages
  1->3 MsgDeFortifyLeader Term:1 Log:0/0
  DEBUG 3 is not fortifying 1; de-fortification is a no-op
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1
  Responses:
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:1 Vote:1 Commit:3 Lead:1 LeadEpoch:0
  Messages:
  2->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:1 Log:0/0 Commit:3 Vote:1 Lead:1
  Responses:

print-fortification-state 1
----
1 : 3
2 : 3

# Note that even though 1 thinks 2 is still fortified, that's not actually the
# case if we look at the raft-state for 2.
raft-state
----
1: StateFollower (Voter) Term:1 Lead:0 LeadEpoch:0
2: StateFollower (Voter) Term:1 Lead:1 LeadEpoch:0
3: StateFollower (Voter) Term:1 Lead:1 LeadEpoch:0

# We've de-fortified 2 successfully. Even then, another attempt to de-fortify
# should go through but effectively no-op.
send-de-fortify 1 2
----
ok

# De-fortifying ourselves should also be a no-op because we de-fortified when
# stepping down.
send-de-fortify 1 1
----
ok

stabilize
----
> 1 handling Ready
  Ready MustSync=false:
  Messages:
  1->2 MsgDeFortifyLeader Term:1 Log:0/0
> 2 receiving messages
  1->2 MsgDeFortifyLeader Term:1 Log:0/0
  DEBUG 2 is not fortifying 1; de-fortification is a no-op

print-fortification-state 1
----
1 : 3
2 : 3

raft-state
----
1: StateFollower (Voter) Term:1 Lead:0 LeadEpoch:0
2: StateFollower (Voter) Term:1 Lead:1 LeadEpoch:0
3: StateFollower (Voter) Term:1 Lead:1 LeadEpoch:0

# Next, set up a test where a leader steps down, but a new one is only elected
# once enough followers are no longer fortifying a leader.

campaign 2
----
INFO 2 is starting a new election at term 1
INFO 2 became candidate at term 2
INFO 2 [logterm: 1, index: 3] sent MsgVote request to 1 at term 2
INFO 2 [logterm: 1, index: 3] sent MsgVote request to 3 at term 2

stabilize
----
> 2 handling Ready
  Ready MustSync=true:
  State:StateCandidate
  HardState Term:2 Vote:2 Commit:3 Lead:0 LeadEpoch:0
  Messages:
  2->1 MsgVote Term:2 Log:1/3
  2->3 MsgVote Term:2 Log:1/3
  2->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:3 Vote:2 Responses:[
    2->2 MsgVoteResp Term:2 Log:0/0
  ]
> 1 receiving messages
  2->1 MsgVote Term:2 Log:1/3
  INFO 1 [term: 1] received a MsgVote message with higher term from 2 [term: 2], advancing term
  INFO 1 became follower at term 2
  DEBUG 1 reset election elapsed to 0
  INFO 1 [logterm: 1, index: 3, vote: 0] cast MsgVote for 2 [logterm: 1, index: 3] at term 2
> 3 receiving messages
  2->3 MsgVote Term:2 Log:1/3
  INFO 3 [term: 1] received a MsgVote message with higher term from 2 [term: 2], advancing term
  INFO 3 became follower at term 2
  DEBUG 3 reset election elapsed to 0
  INFO 3 [logterm: 1, index: 3, vote: 0] cast MsgVote for 2 [logterm: 1, index: 3] at term 2
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:3 Vote:2
  Responses:
  2->2 MsgVoteResp Term:2 Log:0/0
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:3 Lead:0 LeadEpoch:0
  Messages:
  1->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:3 Vote:2 Responses:[
    1->2 MsgVoteResp Term:2 Log:0/0
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:3 Lead:0 LeadEpoch:0
  Messages:
  3->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:3 Vote:2 Responses:[
    3->2 MsgVoteResp Term:2 Log:0/0
  ]
> 2 receiving messages
  2->2 MsgVoteResp Term:2 Log:0/0
  INFO 2 received MsgVoteResp from 2 at term 2
  INFO 2 has received 1 MsgVoteResp votes and 0 vote rejections
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:3 Vote:2
  Responses:
  1->2 MsgVoteResp Term:2 Log:0/0
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:3 Vote:2
  Responses:
  3->2 MsgVoteResp Term:2 Log:0/0
> 2 receiving messages
  1->2 MsgVoteResp Term:2 Log:0/0
  INFO 2 received MsgVoteResp from 1 at term 2
  INFO 2 has received 2 MsgVoteResp votes and 0 vote rejections
  INFO 2 became leader at term 2
  3->2 MsgVoteResp Term:2 Log:0/0
> 2 handling Ready
  Ready MustSync=true:
  State:StateLeader
  HardState Term:2 Vote:2 Commit:3 Lead:2 LeadEpoch:1
  Entries:
  2/4 EntryNormal ""
  Messages:
  2->1 MsgFortifyLeader Term:2 Log:0/0
  2->3 MsgFortifyLeader Term:2 Log:0/0
  2->1 MsgApp Term:2 Log:1/3 Commit:3 Entries:[2/4 EntryNormal ""]
  2->3 MsgApp Term:2 Log:1/3 Commit:3 Entries:[2/4 EntryNormal ""]
  2->AppendThread MsgStorageAppend Term:2 Log:2/4 Commit:3 Vote:2 Lead:2 LeadEpoch:1 Entries:[2/4 EntryNormal ""] Responses:[
    2->2 MsgAppResp Term:2 Log:0/4 Commit:3
    2->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
    AppendThread->2 MsgStorageAppendResp Term:0 Log:2/4
  ]
> 1 receiving messages
  2->1 MsgFortifyLeader Term:2 Log:0/0
  2->1 MsgApp Term:2 Log:1/3 Commit:3 Entries:[2/4 EntryNormal ""]
> 3 receiving messages
  2->3 MsgFortifyLeader Term:2 Log:0/0
  2->3 MsgApp Term:2 Log:1/3 Commit:3 Entries:[2/4 EntryNormal ""]
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:2 Log:2/4 Commit:3 Vote:2 Lead:2 LeadEpoch:1 Entries:[2/4 EntryNormal ""]
  Responses:
  2->2 MsgAppResp Term:2 Log:0/4 Commit:3
  2->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
  AppendThread->2 MsgStorageAppendResp Term:0 Log:2/4
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:3 Lead:2 LeadEpoch:1
  Entries:
  2/4 EntryNormal ""
  Messages:
  1->AppendThread MsgStorageAppend Term:2 Log:2/4 Commit:3 Vote:2 Lead:2 LeadEpoch:1 Entries:[2/4 EntryNormal ""] Responses:[
    1->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
    1->2 MsgAppResp Term:2 Log:0/4 Commit:3
    AppendThread->1 MsgStorageAppendResp Term:0 Log:2/4
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:3 Lead:2 LeadEpoch:1
  Entries:
  2/4 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:2 Log:2/4 Commit:3 Vote:2 Lead:2 LeadEpoch:1 Entries:[2/4 EntryNormal ""] Responses:[
    3->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
    3->2 MsgAppResp Term:2 Log:0/4 Commit:3
    AppendThread->3 MsgStorageAppendResp Term:0 Log:2/4
  ]
> 2 receiving messages
  2->2 MsgAppResp Term:2 Log:0/4 Commit:3
  2->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
  AppendThread->2 MsgStorageAppendResp Term:0 Log:2/4
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:2 Log:2/4 Commit:3 Vote:2 Lead:2 LeadEpoch:1 Entries:[2/4 EntryNormal ""]
  Responses:
  1->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
  1->2 MsgAppResp Term:2 Log:0/4 Commit:3
  AppendThread->1 MsgStorageAppendResp Term:0 Log:2/4
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:2 Log:2/4 Commit:3 Vote:2 Lead:2 LeadEpoch:1 Entries:[2/4 EntryNormal ""]
  Responses:
  3->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
  3->2 MsgAppResp Term:2 Log:0/4 Commit:3
  AppendThread->3 MsgStorageAppendResp Term:0 Log:2/4
> 1 receiving messages
  AppendThread->1 MsgStorageAppendResp Term:0 Log:2/4
> 2 receiving messages
  1->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
  1->2 MsgAppResp Term:2 Log:0/4 Commit:3
  3->2 MsgFortifyLeaderResp Term:2 Log:0/0 LeadEpoch:1
  3->2 MsgAppResp Term:2 Log:0/4 Commit:3
> 3 receiving messages
  AppendThread->3 MsgStorageAppendResp Term:0 Log:2/4
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:4 Lead:2 LeadEpoch:1
  CommittedEntries:
  2/4 EntryNormal ""
  Messages:
  2->1 MsgApp Term:2 Log:1/3 Commit:3 Entries:[2/4 EntryNormal ""]
  2->1 MsgApp Term:2 Log:2/4 Commit:4
  2->3 MsgApp Term:2 Log:1/3 Commit:4 Entries:[2/4 EntryNormal ""]
  2->3 MsgApp Term:2 Log:2/4 Commit:4
  2->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2 LeadEpoch:1
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[2/4 EntryNormal ""] Responses:[
    ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
  ]
> 1 receiving messages
  2->1 MsgApp Term:2 Log:1/3 Commit:3 Entries:[2/4 EntryNormal ""]
  2->1 MsgApp Term:2 Log:2/4 Commit:4
> 3 receiving messages
  2->3 MsgApp Term:2 Log:1/3 Commit:4 Entries:[2/4 EntryNormal ""]
  2->3 MsgApp Term:2 Log:2/4 Commit:4
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2 LeadEpoch:1
  Responses:
> 2 processing apply thread
  Processing:
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
  Responses:
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:4 Lead:2 LeadEpoch:1
  CommittedEntries:
  2/4 EntryNormal ""
  Messages:
  1->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2 LeadEpoch:1 Responses:[
    1->2 MsgAppResp Term:2 Log:0/4 Commit:3
    1->2 MsgAppResp Term:2 Log:0/4 Commit:4
  ]
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[2/4 EntryNormal ""] Responses:[
    ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:4 Lead:2 LeadEpoch:1
  CommittedEntries:
  2/4 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2 LeadEpoch:1 Responses:[
    3->2 MsgAppResp Term:2 Log:0/4 Commit:4
    3->2 MsgAppResp Term:2 Log:0/4 Commit:4
  ]
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[2/4 EntryNormal ""] Responses:[
    ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
  ]
> 2 receiving messages
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2 LeadEpoch:1
  Responses:
  1->2 MsgAppResp Term:2 Log:0/4 Commit:3
  1->2 MsgAppResp Term:2 Log:0/4 Commit:4
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2 LeadEpoch:1
  Responses:
  3->2 MsgAppResp Term:2 Log:0/4 Commit:4
  3->2 MsgAppResp Term:2 Log:0/4 Commit:4
> 1 processing apply thread
  Processing:
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
  Responses:
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
> 3 processing apply thread
  Processing:
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
  Responses:
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
> 1 receiving messages
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]
> 2 receiving messages
  1->2 MsgAppResp Term:2 Log:0/4 Commit:3
  1->2 MsgAppResp Term:2 Log:0/4 Commit:4
  3->2 MsgAppResp Term:2 Log:0/4 Commit:4
  3->2 MsgAppResp Term:2 Log:0/4 Commit:4
> 3 receiving messages
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[2/4 EntryNormal ""]

print-fortification-state 2
----
1 : 1
2 : 1
3 : 1

campaign 3
----
DEBUG 3 ignoring MsgHup due to leader fortification

step-down 2
----
DEBUG 2 setting election elapsed to start from 3 ticks after store liveness support expired
INFO 2 became follower at term 2
DEBUG 2 reset election elapsed to 0

campaign 3
----
DEBUG 3 ignoring MsgHup due to leader fortification

send-de-fortify 2 3
----
ok

stabilize
----
> 2 handling Ready
  Ready MustSync=true:
  State:StateFollower
  HardState Term:2 Vote:2 Commit:4 Lead:0 LeadEpoch:0
  Messages:
  2->3 MsgDeFortifyLeader Term:2 Log:0/0
  2->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2
> 3 receiving messages
  2->3 MsgDeFortifyLeader Term:2 Log:0/0
  DEBUG 3 setting election elapsed to start from 3 ticks after store liveness support expired
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2
  Responses:
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:2 Vote:2 Commit:4 Lead:2 LeadEpoch:0
  Messages:
  3->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:2 Log:0/0 Commit:4 Vote:2 Lead:2
  Responses:

raft-state
----
1: StateFollower (Voter) Term:2 Lead:2 LeadEpoch:1
2: StateFollower (Voter) Term:2 Lead:0 LeadEpoch:0
3: StateFollower (Voter) Term:2 Lead:2 LeadEpoch:0

# Now that 3 has is no longer fortifying 2, it's able to campaign.
campaign 3
----
INFO 3 is starting a new election at term 2
INFO 3 became candidate at term 3
INFO 3 [logterm: 2, index: 4] sent MsgVote request to 1 at term 3
INFO 3 [logterm: 2, index: 4] sent MsgVote request to 2 at term 3

# It should be able to win the election as a quorum is no longer fortifying the
# leader at this point.
stabilize
----
> 3 handling Ready
  Ready MustSync=true:
  State:StateCandidate
  HardState Term:3 Vote:3 Commit:4 Lead:0 LeadEpoch:0
  Messages:
  3->1 MsgVote Term:3 Log:2/4
  3->2 MsgVote Term:3 Log:2/4
  3->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:4 Vote:3 Responses:[
    3->3 MsgVoteResp Term:3 Log:0/0
  ]
> 1 receiving messages
  3->1 MsgVote Term:3 Log:2/4
  INFO 1 [logterm: 2, index: 4, vote: 2] ignored MsgVote from 3 [logterm: 2, index: 4] at term 2: supporting fortified leader 2 at epoch 1
> 2 receiving messages
  3->2 MsgVote Term:3 Log:2/4
  INFO 2 [term: 2] received a MsgVote message with higher term from 3 [term: 3], advancing term
  INFO 2 became follower at term 3
  DEBUG 2 reset election elapsed to 0
  INFO 2 [logterm: 2, index: 4, vote: 0] cast MsgVote for 3 [logterm: 2, index: 4] at term 3
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:4 Vote:3
  Responses:
  3->3 MsgVoteResp Term:3 Log:0/0
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:3 Vote:3 Commit:4 Lead:0 LeadEpoch:0
  Messages:
  2->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:4 Vote:3 Responses:[
    2->3 MsgVoteResp Term:3 Log:0/0
  ]
> 3 receiving messages
  3->3 MsgVoteResp Term:3 Log:0/0
  INFO 3 received MsgVoteResp from 3 at term 3
  INFO 3 has received 1 MsgVoteResp votes and 0 vote rejections
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:4 Vote:3
  Responses:
  2->3 MsgVoteResp Term:3 Log:0/0
> 3 receiving messages
  2->3 MsgVoteResp Term:3 Log:0/0
  INFO 3 received MsgVoteResp from 2 at term 3
  INFO 3 has received 2 MsgVoteResp votes and 0 vote rejections
  INFO 3 became leader at term 3
> 3 handling Ready
  Ready MustSync=true:
  State:StateLeader
  HardState Term:3 Vote:3 Commit:4 Lead:3 LeadEpoch:1
  Entries:
  3/5 EntryNormal ""
  Messages:
  3->1 MsgFortifyLeader Term:3 Log:0/0
  3->2 MsgFortifyLeader Term:3 Log:0/0
  3->1 MsgApp Term:3 Log:2/4 Commit:4 Entries:[3/5 EntryNormal ""]
  3->2 MsgApp Term:3 Log:2/4 Commit:4 Entries:[3/5 EntryNormal ""]
  3->AppendThread MsgStorageAppend Term:3 Log:3/5 Commit:4 Vote:3 Lead:3 LeadEpoch:1 Entries:[3/5 EntryNormal ""] Responses:[
    3->3 MsgAppResp Term:3 Log:0/5 Commit:4
    3->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
    AppendThread->3 MsgStorageAppendResp Term:0 Log:3/5
  ]
> 1 receiving messages
  3->1 MsgFortifyLeader Term:3 Log:0/0
  INFO 1 [term: 2] received a MsgFortifyLeader message with higher term from 3 [term: 3], new leader indicated, advancing term
  DEBUG 1 setting election elapsed to start from 3 ticks after store liveness support expired
  INFO 1 became follower at term 3
  DEBUG 1 reset election elapsed to 0
  3->1 MsgApp Term:3 Log:2/4 Commit:4 Entries:[3/5 EntryNormal ""]
> 2 receiving messages
  3->2 MsgFortifyLeader Term:3 Log:0/0
  3->2 MsgApp Term:3 Log:2/4 Commit:4 Entries:[3/5 EntryNormal ""]
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:3 Log:3/5 Commit:4 Vote:3 Lead:3 LeadEpoch:1 Entries:[3/5 EntryNormal ""]
  Responses:
  3->3 MsgAppResp Term:3 Log:0/5 Commit:4
  3->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
  AppendThread->3 MsgStorageAppendResp Term:0 Log:3/5
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:3 Commit:4 Lead:3 LeadEpoch:1
  Entries:
  3/5 EntryNormal ""
  Messages:
  1->AppendThread MsgStorageAppend Term:3 Log:3/5 Commit:4 Lead:3 LeadEpoch:1 Entries:[3/5 EntryNormal ""] Responses:[
    1->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
    1->3 MsgAppResp Term:3 Log:0/5 Commit:4
    AppendThread->1 MsgStorageAppendResp Term:0 Log:3/5
  ]
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:3 Vote:3 Commit:4 Lead:3 LeadEpoch:1
  Entries:
  3/5 EntryNormal ""
  Messages:
  2->AppendThread MsgStorageAppend Term:3 Log:3/5 Commit:4 Vote:3 Lead:3 LeadEpoch:1 Entries:[3/5 EntryNormal ""] Responses:[
    2->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
    2->3 MsgAppResp Term:3 Log:0/5 Commit:4
    AppendThread->2 MsgStorageAppendResp Term:0 Log:3/5
  ]
> 3 receiving messages
  3->3 MsgAppResp Term:3 Log:0/5 Commit:4
  3->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
  AppendThread->3 MsgStorageAppendResp Term:0 Log:3/5
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:3 Log:3/5 Commit:4 Lead:3 LeadEpoch:1 Entries:[3/5 EntryNormal ""]
  Responses:
  1->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
  1->3 MsgAppResp Term:3 Log:0/5 Commit:4
  AppendThread->1 MsgStorageAppendResp Term:0 Log:3/5
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:3 Log:3/5 Commit:4 Vote:3 Lead:3 LeadEpoch:1 Entries:[3/5 EntryNormal ""]
  Responses:
  2->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
  2->3 MsgAppResp Term:3 Log:0/5 Commit:4
  AppendThread->2 MsgStorageAppendResp Term:0 Log:3/5
> 1 receiving messages
  AppendThread->1 MsgStorageAppendResp Term:0 Log:3/5
> 2 receiving messages
  AppendThread->2 MsgStorageAppendResp Term:0 Log:3/5
> 3 receiving messages
  1->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
  1->3 MsgAppResp Term:3 Log:0/5 Commit:4
  2->3 MsgFortifyLeaderResp Term:3 Log:0/0 LeadEpoch:1
  2->3 MsgAppResp Term:3 Log:0/5 Commit:4
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:3 Vote:3 Commit:5 Lead:3 LeadEpoch:1
  CommittedEntries:
  3/5 EntryNormal ""
  Messages:
  3->1 MsgApp Term:3 Log:2/4 Commit:4 Entries:[3/5 EntryNormal ""]
  3->1 MsgApp Term:3 Log:3/5 Commit:5
  3->2 MsgApp Term:3 Log:2/4 Commit:5 Entries:[3/5 EntryNormal ""]
  3->2 MsgApp Term:3 Log:3/5 Commit:5
  3->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:5 Vote:3 Lead:3 LeadEpoch:1
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[3/5 EntryNormal ""] Responses:[
    ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
  ]
> 1 receiving messages
  3->1 MsgApp Term:3 Log:2/4 Commit:4 Entries:[3/5 EntryNormal ""]
  3->1 MsgApp Term:3 Log:3/5 Commit:5
> 2 receiving messages
  3->2 MsgApp Term:3 Log:2/4 Commit:5 Entries:[3/5 EntryNormal ""]
  3->2 MsgApp Term:3 Log:3/5 Commit:5
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:5 Vote:3 Lead:3 LeadEpoch:1
  Responses:
> 3 processing apply thread
  Processing:
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
  Responses:
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:3 Commit:5 Lead:3 LeadEpoch:1
  CommittedEntries:
  3/5 EntryNormal ""
  Messages:
  1->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:5 Lead:3 LeadEpoch:1 Responses:[
    1->3 MsgAppResp Term:3 Log:0/5 Commit:4
    1->3 MsgAppResp Term:3 Log:0/5 Commit:5
  ]
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[3/5 EntryNormal ""] Responses:[
    ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
  ]
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:3 Vote:3 Commit:5 Lead:3 LeadEpoch:1
  CommittedEntries:
  3/5 EntryNormal ""
  Messages:
  2->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:5 Vote:3 Lead:3 LeadEpoch:1 Responses:[
    2->3 MsgAppResp Term:3 Log:0/5 Commit:5
    2->3 MsgAppResp Term:3 Log:0/5 Commit:5
  ]
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[3/5 EntryNormal ""] Responses:[
    ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
  ]
> 3 receiving messages
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:5 Lead:3 LeadEpoch:1
  Responses:
  1->3 MsgAppResp Term:3 Log:0/5 Commit:4
  1->3 MsgAppResp Term:3 Log:0/5 Commit:5
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:3 Log:0/0 Commit:5 Vote:3 Lead:3 LeadEpoch:1
  Responses:
  2->3 MsgAppResp Term:3 Log:0/5 Commit:5
  2->3 MsgAppResp Term:3 Log:0/5 Commit:5
> 1 processing apply thread
  Processing:
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
  Responses:
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
> 2 processing apply thread
  Processing:
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
  Responses:
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
> 1 receiving messages
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
> 2 receiving messages
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[3/5 EntryNormal ""]
> 3 receiving messages
  1->3 MsgAppResp Term:3 Log:0/5 Commit:4
  1->3 MsgAppResp Term:3 Log:0/5 Commit:5
  2->3 MsgAppResp Term:3 Log:0/5 Commit:5
  2->3 MsgAppResp Term:3 Log:0/5 Commit:5

raft-state
----
1: StateFollower (Voter) Term:3 Lead:3 LeadEpoch:1
2: StateFollower (Voter) Term:3 Lead:3 LeadEpoch:1
3: StateLeader (Voter) Term:3 Lead:3 LeadEpoch:1

# Ensure that the leader sends out MsgDeFortifyLeader messages for the correct
# term. In particular, the term from its leadership stint (2), not the term
# currently known to it.

# 2 was the leader before 3 was elected.
print-fortification-state 2
----
1 : 1
2 : 1
3 : 1

send-de-fortify 2 1
----
ok

send-de-fortify 2 3
----
ok

stabilize
----
> 2 handling Ready
  Ready MustSync=false:
  Messages:
  2->1 MsgDeFortifyLeader Term:2 Log:0/0
  2->3 MsgDeFortifyLeader Term:2 Log:0/0
> 1 receiving messages
  2->1 MsgDeFortifyLeader Term:2 Log:0/0
  INFO 1 [term: 3] ignored a MsgDeFortifyLeader message with lower term from 2 [term: 2]
> 3 receiving messages
  2->3 MsgDeFortifyLeader Term:2 Log:0/0
  INFO 3 [term: 3] ignored a MsgDeFortifyLeader message with lower term from 2 [term: 2]

# Ensure that when 2 steps up, steps down, and then de-fortifies again, it does
# so at the correct term.
bump-epoch 3
----
  1 2 3
1 3 1 2
2 3 1 2
3 x 1 2

campaign 2
----
INFO 2 is starting a new election at term 3
INFO 2 became candidate at term 4
INFO 2 [logterm: 3, index: 5] sent MsgVote request to 1 at term 4
INFO 2 [logterm: 3, index: 5] sent MsgVote request to 3 at term 4

stabilize
----
> 2 handling Ready
  Ready MustSync=true:
  State:StateCandidate
  HardState Term:4 Vote:2 Commit:5 Lead:0 LeadEpoch:0
  Messages:
  2->1 MsgVote Term:4 Log:3/5
  2->3 MsgVote Term:4 Log:3/5
  2->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:5 Vote:2 Responses:[
    2->2 MsgVoteResp Term:4 Log:0/0
  ]
> 1 receiving messages
  2->1 MsgVote Term:4 Log:3/5
  DEBUG 1 setting election elapsed to start from 3 ticks after store liveness support expired
  INFO 1 [term: 3] received a MsgVote message with higher term from 2 [term: 4], advancing term
  INFO 1 became follower at term 4
  DEBUG 1 reset election elapsed to 0
  INFO 1 [logterm: 3, index: 5, vote: 0] cast MsgVote for 2 [logterm: 3, index: 5] at term 4
> 3 receiving messages
  2->3 MsgVote Term:4 Log:3/5
  DEBUG 3 setting election elapsed to start from 3 ticks after store liveness support expired
  INFO 3 [term: 3] received a MsgVote message with higher term from 2 [term: 4], advancing term
  INFO 3 became follower at term 4
  DEBUG 3 reset election elapsed to 0
  INFO 3 [logterm: 3, index: 5, vote: 0] cast MsgVote for 2 [logterm: 3, index: 5] at term 4
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:5 Vote:2
  Responses:
  2->2 MsgVoteResp Term:4 Log:0/0
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:5 Lead:0 LeadEpoch:0
  Messages:
  1->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:5 Vote:2 Responses:[
    1->2 MsgVoteResp Term:4 Log:0/0
  ]
> 3 handling Ready
  Ready MustSync=true:
  State:StateFollower
  HardState Term:4 Vote:2 Commit:5 Lead:0 LeadEpoch:0
  Messages:
  3->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:5 Vote:2 Responses:[
    3->2 MsgVoteResp Term:4 Log:0/0
  ]
> 2 receiving messages
  2->2 MsgVoteResp Term:4 Log:0/0
  INFO 2 received MsgVoteResp from 2 at term 4
  INFO 2 has received 1 MsgVoteResp votes and 0 vote rejections
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:5 Vote:2
  Responses:
  1->2 MsgVoteResp Term:4 Log:0/0
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:5 Vote:2
  Responses:
  3->2 MsgVoteResp Term:4 Log:0/0
> 2 receiving messages
  1->2 MsgVoteResp Term:4 Log:0/0
  INFO 2 received MsgVoteResp from 1 at term 4
  INFO 2 has received 2 MsgVoteResp votes and 0 vote rejections
  INFO 2 became leader at term 4
  3->2 MsgVoteResp Term:4 Log:0/0
> 2 handling Ready
  Ready MustSync=true:
  State:StateLeader
  HardState Term:4 Vote:2 Commit:5 Lead:2 LeadEpoch:1
  Entries:
  4/6 EntryNormal ""
  Messages:
  2->1 MsgFortifyLeader Term:4 Log:0/0
  2->3 MsgFortifyLeader Term:4 Log:0/0
  2->1 MsgApp Term:4 Log:3/5 Commit:5 Entries:[4/6 EntryNormal ""]
  2->3 MsgApp Term:4 Log:3/5 Commit:5 Entries:[4/6 EntryNormal ""]
  2->AppendThread MsgStorageAppend Term:4 Log:4/6 Commit:5 Vote:2 Lead:2 LeadEpoch:1 Entries:[4/6 EntryNormal ""] Responses:[
    2->2 MsgAppResp Term:4 Log:0/6 Commit:5
    2->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
    AppendThread->2 MsgStorageAppendResp Term:0 Log:4/6
  ]
> 1 receiving messages
  2->1 MsgFortifyLeader Term:4 Log:0/0
  2->1 MsgApp Term:4 Log:3/5 Commit:5 Entries:[4/6 EntryNormal ""]
> 3 receiving messages
  2->3 MsgFortifyLeader Term:4 Log:0/0
  2->3 MsgApp Term:4 Log:3/5 Commit:5 Entries:[4/6 EntryNormal ""]
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:4 Log:4/6 Commit:5 Vote:2 Lead:2 LeadEpoch:1 Entries:[4/6 EntryNormal ""]
  Responses:
  2->2 MsgAppResp Term:4 Log:0/6 Commit:5
  2->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
  AppendThread->2 MsgStorageAppendResp Term:0 Log:4/6
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:5 Lead:2 LeadEpoch:1
  Entries:
  4/6 EntryNormal ""
  Messages:
  1->AppendThread MsgStorageAppend Term:4 Log:4/6 Commit:5 Vote:2 Lead:2 LeadEpoch:1 Entries:[4/6 EntryNormal ""] Responses:[
    1->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
    1->2 MsgAppResp Term:4 Log:0/6 Commit:5
    AppendThread->1 MsgStorageAppendResp Term:0 Log:4/6
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:5 Lead:2 LeadEpoch:1
  Entries:
  4/6 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:4 Log:4/6 Commit:5 Vote:2 Lead:2 LeadEpoch:1 Entries:[4/6 EntryNormal ""] Responses:[
    3->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
    3->2 MsgAppResp Term:4 Log:0/6 Commit:5
    AppendThread->3 MsgStorageAppendResp Term:0 Log:4/6
  ]
> 2 receiving messages
  2->2 MsgAppResp Term:4 Log:0/6 Commit:5
  2->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
  AppendThread->2 MsgStorageAppendResp Term:0 Log:4/6
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:4 Log:4/6 Commit:5 Vote:2 Lead:2 LeadEpoch:1 Entries:[4/6 EntryNormal ""]
  Responses:
  1->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
  1->2 MsgAppResp Term:4 Log:0/6 Commit:5
  AppendThread->1 MsgStorageAppendResp Term:0 Log:4/6
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:4 Log:4/6 Commit:5 Vote:2 Lead:2 LeadEpoch:1 Entries:[4/6 EntryNormal ""]
  Responses:
  3->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
  3->2 MsgAppResp Term:4 Log:0/6 Commit:5
  AppendThread->3 MsgStorageAppendResp Term:0 Log:4/6
> 1 receiving messages
  AppendThread->1 MsgStorageAppendResp Term:0 Log:4/6
> 2 receiving messages
  1->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
  1->2 MsgAppResp Term:4 Log:0/6 Commit:5
  3->2 MsgFortifyLeaderResp Term:4 Log:0/0 LeadEpoch:1
  3->2 MsgAppResp Term:4 Log:0/6 Commit:5
> 3 receiving messages
  AppendThread->3 MsgStorageAppendResp Term:0 Log:4/6
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:6 Lead:2 LeadEpoch:1
  CommittedEntries:
  4/6 EntryNormal ""
  Messages:
  2->1 MsgApp Term:4 Log:3/5 Commit:5 Entries:[4/6 EntryNormal ""]
  2->1 MsgApp Term:4 Log:4/6 Commit:6
  2->3 MsgApp Term:4 Log:3/5 Commit:6 Entries:[4/6 EntryNormal ""]
  2->3 MsgApp Term:4 Log:4/6 Commit:6
  2->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2 LeadEpoch:1
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[4/6 EntryNormal ""] Responses:[
    ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
  ]
> 1 receiving messages
  2->1 MsgApp Term:4 Log:3/5 Commit:5 Entries:[4/6 EntryNormal ""]
  2->1 MsgApp Term:4 Log:4/6 Commit:6
> 3 receiving messages
  2->3 MsgApp Term:4 Log:3/5 Commit:6 Entries:[4/6 EntryNormal ""]
  2->3 MsgApp Term:4 Log:4/6 Commit:6
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2 LeadEpoch:1
  Responses:
> 2 processing apply thread
  Processing:
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
  Responses:
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:6 Lead:2 LeadEpoch:1
  CommittedEntries:
  4/6 EntryNormal ""
  Messages:
  1->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2 LeadEpoch:1 Responses:[
    1->2 MsgAppResp Term:4 Log:0/6 Commit:5
    1->2 MsgAppResp Term:4 Log:0/6 Commit:6
  ]
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[4/6 EntryNormal ""] Responses:[
    ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:6 Lead:2 LeadEpoch:1
  CommittedEntries:
  4/6 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2 LeadEpoch:1 Responses:[
    3->2 MsgAppResp Term:4 Log:0/6 Commit:6
    3->2 MsgAppResp Term:4 Log:0/6 Commit:6
  ]
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[4/6 EntryNormal ""] Responses:[
    ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
  ]
> 2 receiving messages
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2 LeadEpoch:1
  Responses:
  1->2 MsgAppResp Term:4 Log:0/6 Commit:5
  1->2 MsgAppResp Term:4 Log:0/6 Commit:6
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2 LeadEpoch:1
  Responses:
  3->2 MsgAppResp Term:4 Log:0/6 Commit:6
  3->2 MsgAppResp Term:4 Log:0/6 Commit:6
> 1 processing apply thread
  Processing:
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
  Responses:
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
> 3 processing apply thread
  Processing:
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
  Responses:
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
> 1 receiving messages
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]
> 2 receiving messages
  1->2 MsgAppResp Term:4 Log:0/6 Commit:5
  1->2 MsgAppResp Term:4 Log:0/6 Commit:6
  3->2 MsgAppResp Term:4 Log:0/6 Commit:6
  3->2 MsgAppResp Term:4 Log:0/6 Commit:6
> 3 receiving messages
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[4/6 EntryNormal ""]

raft-state
----
1: StateFollower (Voter) Term:4 Lead:2 LeadEpoch:1
2: StateLeader (Voter) Term:4 Lead:2 LeadEpoch:1
3: StateFollower (Voter) Term:4 Lead:2 LeadEpoch:1

# Have 2 withdraw support from itself before stepping down.
withdraw-support 2 2
----
  1 2 3
1 3 1 2
2 3 x 2
3 x 1 2

step-down 2
----
DEBUG 2 setting election elapsed to start from 3 ticks after store liveness support expired
INFO 2 became follower at term 4
DEBUG 2 reset election elapsed to 0

send-de-fortify 2 1
----
ok

stabilize
----
> 2 handling Ready
  Ready MustSync=true:
  State:StateFollower
  HardState Term:4 Vote:2 Commit:6 Lead:0 LeadEpoch:0
  Messages:
  2->1 MsgDeFortifyLeader Term:4 Log:0/0
  2->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2
> 1 receiving messages
  2->1 MsgDeFortifyLeader Term:4 Log:0/0
  DEBUG 1 setting election elapsed to start from 3 ticks after store liveness support expired
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2
  Responses:
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:4 Vote:2 Commit:6 Lead:2 LeadEpoch:0
  Messages:
  1->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:4 Log:0/0 Commit:6 Vote:2 Lead:2
  Responses:

raft-state
----
1: StateFollower (Voter) Term:4 Lead:2 LeadEpoch:0
2: StateFollower (Voter) Term:4 Lead:0 LeadEpoch:0
3: StateFollower (Voter) Term:4 Lead:2 LeadEpoch:1

campaign 1
----
INFO 1 is starting a new election at term 4
INFO 1 became candidate at term 5
INFO 1 [logterm: 4, index: 6] sent MsgVote request to 2 at term 5
INFO 1 [logterm: 4, index: 6] sent MsgVote request to 3 at term 5

stabilize
----
> 1 handling Ready
  Ready MustSync=true:
  State:StateCandidate
  HardState Term:5 Vote:1 Commit:6 Lead:0 LeadEpoch:0
  Messages:
  1->2 MsgVote Term:5 Log:4/6
  1->3 MsgVote Term:5 Log:4/6
  1->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:6 Vote:1 Responses:[
    1->1 MsgVoteResp Term:5 Log:0/0
  ]
> 2 receiving messages
  1->2 MsgVote Term:5 Log:4/6
  INFO 2 [term: 4] received a MsgVote message with higher term from 1 [term: 5], advancing term
  INFO 2 became follower at term 5
  DEBUG 2 reset election elapsed to 0
  INFO 2 [logterm: 4, index: 6, vote: 0] cast MsgVote for 1 [logterm: 4, index: 6] at term 5
> 3 receiving messages
  1->3 MsgVote Term:5 Log:4/6
  INFO 3 [logterm: 4, index: 6, vote: 2] ignored MsgVote from 1 [logterm: 4, index: 6] at term 4: supporting fortified leader 2 at epoch 1
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:6 Vote:1
  Responses:
  1->1 MsgVoteResp Term:5 Log:0/0
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:5 Vote:1 Commit:6 Lead:0 LeadEpoch:0
  Messages:
  2->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:6 Vote:1 Responses:[
    2->1 MsgVoteResp Term:5 Log:0/0
  ]
> 1 receiving messages
  1->1 MsgVoteResp Term:5 Log:0/0
  INFO 1 received MsgVoteResp from 1 at term 5
  INFO 1 has received 1 MsgVoteResp votes and 0 vote rejections
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:6 Vote:1
  Responses:
  2->1 MsgVoteResp Term:5 Log:0/0
> 1 receiving messages
  2->1 MsgVoteResp Term:5 Log:0/0
  INFO 1 received MsgVoteResp from 2 at term 5
  INFO 1 has received 2 MsgVoteResp votes and 0 vote rejections
  INFO 1 became leader at term 5
> 1 handling Ready
  Ready MustSync=true:
  State:StateLeader
  HardState Term:5 Vote:1 Commit:6 Lead:1 LeadEpoch:3
  Entries:
  5/7 EntryNormal ""
  Messages:
  1->2 MsgFortifyLeader Term:5 Log:0/0
  1->2 MsgApp Term:5 Log:4/6 Commit:6 Entries:[5/7 EntryNormal ""]
  1->3 MsgApp Term:5 Log:4/6 Commit:6 Entries:[5/7 EntryNormal ""]
  1->AppendThread MsgStorageAppend Term:5 Log:5/7 Commit:6 Vote:1 Lead:1 LeadEpoch:3 Entries:[5/7 EntryNormal ""] Responses:[
    1->1 MsgAppResp Term:5 Log:0/7 Commit:6
    1->1 MsgFortifyLeaderResp Term:5 Log:0/0 LeadEpoch:3
    AppendThread->1 MsgStorageAppendResp Term:0 Log:5/7
  ]
> 2 receiving messages
  1->2 MsgFortifyLeader Term:5 Log:0/0
  1->2 MsgApp Term:5 Log:4/6 Commit:6 Entries:[5/7 EntryNormal ""]
> 3 receiving messages
  1->3 MsgApp Term:5 Log:4/6 Commit:6 Entries:[5/7 EntryNormal ""]
  INFO 3 [term: 4] received a MsgApp message with higher term from 1 [term: 5], new leader indicated, advancing term
  DEBUG 3 setting election elapsed to start from 3 ticks after store liveness support expired
  INFO 3 became follower at term 5
  DEBUG 3 reset election elapsed to 0
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:5 Log:5/7 Commit:6 Vote:1 Lead:1 LeadEpoch:3 Entries:[5/7 EntryNormal ""]
  Responses:
  1->1 MsgAppResp Term:5 Log:0/7 Commit:6
  1->1 MsgFortifyLeaderResp Term:5 Log:0/0 LeadEpoch:3
  AppendThread->1 MsgStorageAppendResp Term:0 Log:5/7
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:5 Vote:1 Commit:6 Lead:1 LeadEpoch:3
  Entries:
  5/7 EntryNormal ""
  Messages:
  2->AppendThread MsgStorageAppend Term:5 Log:5/7 Commit:6 Vote:1 Lead:1 LeadEpoch:3 Entries:[5/7 EntryNormal ""] Responses:[
    2->1 MsgFortifyLeaderResp Term:5 Log:0/0 LeadEpoch:3
    2->1 MsgAppResp Term:5 Log:0/7 Commit:6
    AppendThread->2 MsgStorageAppendResp Term:0 Log:5/7
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:5 Commit:6 Lead:1 LeadEpoch:0
  Entries:
  5/7 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:5 Log:5/7 Commit:6 Lead:1 Entries:[5/7 EntryNormal ""] Responses:[
    3->1 MsgAppResp Term:5 Log:0/7 Commit:6
    AppendThread->3 MsgStorageAppendResp Term:0 Log:5/7
  ]
> 1 receiving messages
  1->1 MsgAppResp Term:5 Log:0/7 Commit:6
  1->1 MsgFortifyLeaderResp Term:5 Log:0/0 LeadEpoch:3
  AppendThread->1 MsgStorageAppendResp Term:0 Log:5/7
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:5 Log:5/7 Commit:6 Vote:1 Lead:1 LeadEpoch:3 Entries:[5/7 EntryNormal ""]
  Responses:
  2->1 MsgFortifyLeaderResp Term:5 Log:0/0 LeadEpoch:3
  2->1 MsgAppResp Term:5 Log:0/7 Commit:6
  AppendThread->2 MsgStorageAppendResp Term:0 Log:5/7
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:5 Log:5/7 Commit:6 Lead:1 Entries:[5/7 EntryNormal ""]
  Responses:
  3->1 MsgAppResp Term:5 Log:0/7 Commit:6
  AppendThread->3 MsgStorageAppendResp Term:0 Log:5/7
> 1 receiving messages
  2->1 MsgFortifyLeaderResp Term:5 Log:0/0 LeadEpoch:3
  2->1 MsgAppResp Term:5 Log:0/7 Commit:6
  3->1 MsgAppResp Term:5 Log:0/7 Commit:6
> 2 receiving messages
  AppendThread->2 MsgStorageAppendResp Term:0 Log:5/7
> 3 receiving messages
  AppendThread->3 MsgStorageAppendResp Term:0 Log:5/7
> 1 handling Ready
  Ready MustSync=true:
  HardState Term:5 Vote:1 Commit:7 Lead:1 LeadEpoch:3
  CommittedEntries:
  5/7 EntryNormal ""
  Messages:
  1->2 MsgApp Term:5 Log:4/6 Commit:6 Entries:[5/7 EntryNormal ""]
  1->2 MsgApp Term:5 Log:5/7 Commit:7
  1->3 MsgApp Term:5 Log:5/7 Commit:7
  1->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:7 Vote:1 Lead:1 LeadEpoch:3
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[5/7 EntryNormal ""] Responses:[
    ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
  ]
> 2 receiving messages
  1->2 MsgApp Term:5 Log:4/6 Commit:6 Entries:[5/7 EntryNormal ""]
  1->2 MsgApp Term:5 Log:5/7 Commit:7
> 3 receiving messages
  1->3 MsgApp Term:5 Log:5/7 Commit:7
> 1 processing append thread
  Processing:
  1->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:7 Vote:1 Lead:1 LeadEpoch:3
  Responses:
> 1 processing apply thread
  Processing:
  1->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
  Responses:
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
> 2 handling Ready
  Ready MustSync=true:
  HardState Term:5 Vote:1 Commit:7 Lead:1 LeadEpoch:3
  CommittedEntries:
  5/7 EntryNormal ""
  Messages:
  2->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:7 Vote:1 Lead:1 LeadEpoch:3 Responses:[
    2->1 MsgAppResp Term:5 Log:0/7 Commit:6
    2->1 MsgAppResp Term:5 Log:0/7 Commit:7
  ]
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[5/7 EntryNormal ""] Responses:[
    ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
  ]
> 3 handling Ready
  Ready MustSync=true:
  HardState Term:5 Commit:7 Lead:1 LeadEpoch:0
  CommittedEntries:
  5/7 EntryNormal ""
  Messages:
  3->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:7 Lead:1 Responses:[
    3->1 MsgAppResp Term:5 Log:0/7 Commit:7
  ]
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[5/7 EntryNormal ""] Responses:[
    ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
  ]
> 1 receiving messages
  ApplyThread->1 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
> 2 processing append thread
  Processing:
  2->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:7 Vote:1 Lead:1 LeadEpoch:3
  Responses:
  2->1 MsgAppResp Term:5 Log:0/7 Commit:6
  2->1 MsgAppResp Term:5 Log:0/7 Commit:7
> 3 processing append thread
  Processing:
  3->AppendThread MsgStorageAppend Term:5 Log:0/0 Commit:7 Lead:1
  Responses:
  3->1 MsgAppResp Term:5 Log:0/7 Commit:7
> 2 processing apply thread
  Processing:
  2->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
  Responses:
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
> 3 processing apply thread
  Processing:
  3->ApplyThread MsgStorageApply Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
  Responses:
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
> 1 receiving messages
  2->1 MsgAppResp Term:5 Log:0/7 Commit:6
  2->1 MsgAppResp Term:5 Log:0/7 Commit:7
  3->1 MsgAppResp Term:5 Log:0/7 Commit:7
> 2 receiving messages
  ApplyThread->2 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]
> 3 receiving messages
  ApplyThread->3 MsgStorageApplyResp Term:0 Log:0/0 Entries:[5/7 EntryNormal ""]

raft-state
----
1: StateLeader (Voter) Term:5 Lead:1 LeadEpoch:3
2: StateFollower (Voter) Term:5 Lead:1 LeadEpoch:3
3: StateFollower (Voter) Term:5 Lead:1 LeadEpoch:0

# Ensure 2 sends a MsgDeFortifyLeader at term 4 (not term 2).
send-de-fortify 2 1
----
ok

stabilize
----
> 2 handling Ready
  Ready MustSync=false:
  Messages:
  2->1 MsgDeFortifyLeader Term:4 Log:0/0
> 1 receiving messages
  2->1 MsgDeFortifyLeader Term:4 Log:0/0
  INFO 1 [term: 5] ignored a MsgDeFortifyLeader message with lower term from 2 [term: 4]
