...

Text file src/go.etcd.io/etcd/raft/v3/testdata/campaign_learner_must_vote.txt

Documentation: go.etcd.io/etcd/raft/v3/testdata

     1# Regression test that verifies that learners can vote. This holds only in the
     2# sense that if a learner is asked to vote, a candidate believes that they are a
     3# voter based on its current config, which may be more recent than that of the
     4# learner. If learners which are actually voters but don't know it yet don't
     5# vote in that situation, the raft group may end up unavailable despite a quorum
     6# of voters (as of the latest config) being available.
     7#
     8# See:
     9# https://github.com/etcd-io/etcd/pull/10998
    10
    11# Turn output off during boilerplate.
    12log-level none
    13----
    14ok
    15
    16# Bootstrap three nodes.
    17add-nodes 3 voters=(1,2) learners=(3) index=2
    18----
    19ok
    20
    21# n1 gets to be leader.
    22campaign 1
    23----
    24ok
    25
    26stabilize
    27----
    28ok (quiet)
    29
    30# Propose a conf change on n1 that promotes n3 to voter.
    31propose-conf-change 1
    32v3
    33----
    34ok
    35
    36# Commit and fully apply said conf change. n1 and n2 now consider n3 a voter.
    37stabilize 1 2
    38----
    39ok (quiet)
    40
    41# Drop all inflight messages to 3. We don't want it to be caught up when it is
    42# asked to vote.
    43deliver-msgs drop=(3)
    44----
    45ok (quiet)
    46
    47# We now pretend that n1 is dead, and n2 is trying to become leader.
    48
    49log-level debug
    50----
    51ok
    52
    53campaign 2
    54----
    55INFO 2 is starting a new election at term 1
    56INFO 2 became candidate at term 2
    57INFO 2 received MsgVoteResp from 2 at term 2
    58INFO 2 [logterm: 1, index: 4] sent MsgVote request to 1 at term 2
    59INFO 2 [logterm: 1, index: 4] sent MsgVote request to 3 at term 2
    60
    61# Send out the MsgVote requests.
    62process-ready 2
    63----
    64Ready MustSync=true:
    65Lead:0 State:StateCandidate
    66HardState Term:2 Vote:2 Commit:4
    67Messages:
    682->1 MsgVote Term:2 Log:1/4
    692->3 MsgVote Term:2 Log:1/4
    70
    71# n2 is now campaigning while n1 is down (does not respond). The latest config
    72# has n3 as a voter, but n3 doesn't even have the corresponding conf change in
    73# its log. Still, it casts a vote for n2 which can in turn become leader and
    74# catches up n3.
    75stabilize 3
    76----
    77> 3 receiving messages
    78  2->3 MsgVote Term:2 Log:1/4
    79  INFO 3 [term: 1] received a MsgVote message with higher term from 2 [term: 2]
    80  INFO 3 became follower at term 2
    81  INFO 3 [logterm: 1, index: 3, vote: 0] cast MsgVote for 2 [logterm: 1, index: 4] at term 2
    82> 3 handling Ready
    83  Ready MustSync=true:
    84  Lead:0 State:StateFollower
    85  HardState Term:2 Vote:2 Commit:3
    86  Messages:
    87  3->2 MsgVoteResp Term:2 Log:0/0
    88
    89stabilize 2 3
    90----
    91> 2 receiving messages
    92  3->2 MsgVoteResp Term:2 Log:0/0
    93  INFO 2 received MsgVoteResp from 3 at term 2
    94  INFO 2 has received 2 MsgVoteResp votes and 0 vote rejections
    95  INFO 2 became leader at term 2
    96> 2 handling Ready
    97  Ready MustSync=true:
    98  Lead:2 State:StateLeader
    99  Entries:
   100  2/5 EntryNormal ""
   101  Messages:
   102  2->1 MsgApp Term:2 Log:1/4 Commit:4 Entries:[2/5 EntryNormal ""]
   103  2->3 MsgApp Term:2 Log:1/4 Commit:4 Entries:[2/5 EntryNormal ""]
   104> 3 receiving messages
   105  2->3 MsgApp Term:2 Log:1/4 Commit:4 Entries:[2/5 EntryNormal ""]
   106  DEBUG 3 [logterm: 0, index: 4] rejected MsgApp [logterm: 1, index: 4] from 2
   107> 3 handling Ready
   108  Ready MustSync=false:
   109  Lead:2 State:StateFollower
   110  Messages:
   111  3->2 MsgAppResp Term:2 Log:1/4 Rejected (Hint: 3)
   112> 2 receiving messages
   113  3->2 MsgAppResp Term:2 Log:1/4 Rejected (Hint: 3)
   114  DEBUG 2 received MsgAppResp(rejected, hint: (index 3, term 1)) from 3 for index 4
   115  DEBUG 2 decreased progress of 3 to [StateProbe match=0 next=4]
   116> 2 handling Ready
   117  Ready MustSync=false:
   118  Messages:
   119  2->3 MsgApp Term:2 Log:1/3 Commit:4 Entries:[1/4 EntryConfChangeV2 v3, 2/5 EntryNormal ""]
   120> 3 receiving messages
   121  2->3 MsgApp Term:2 Log:1/3 Commit:4 Entries:[1/4 EntryConfChangeV2 v3, 2/5 EntryNormal ""]
   122> 3 handling Ready
   123  Ready MustSync=true:
   124  HardState Term:2 Vote:2 Commit:4
   125  Entries:
   126  1/4 EntryConfChangeV2 v3
   127  2/5 EntryNormal ""
   128  CommittedEntries:
   129  1/4 EntryConfChangeV2 v3
   130  Messages:
   131  3->2 MsgAppResp Term:2 Log:0/5
   132  INFO 3 switched to configuration voters=(1 2 3)
   133> 2 receiving messages
   134  3->2 MsgAppResp Term:2 Log:0/5
   135> 2 handling Ready
   136  Ready MustSync=false:
   137  HardState Term:2 Vote:2 Commit:5
   138  CommittedEntries:
   139  2/5 EntryNormal ""
   140  Messages:
   141  2->3 MsgApp Term:2 Log:2/5 Commit:5
   142> 3 receiving messages
   143  2->3 MsgApp Term:2 Log:2/5 Commit:5
   144> 3 handling Ready
   145  Ready MustSync=false:
   146  HardState Term:2 Vote:2 Commit:5
   147  CommittedEntries:
   148  2/5 EntryNormal ""
   149  Messages:
   150  3->2 MsgAppResp Term:2 Log:0/5
   151> 2 receiving messages
   152  3->2 MsgAppResp Term:2 Log:0/5

View as plain text