-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raft: add a batch of interaction-driven conf change tests
Verifiy the behavior in various v1 and v2 conf change operations. This also includes various fixups, notably it adds protection against transitioning in and out of new configs when this is not permissible. There are more threads to pull, but those are left for future commits.
- Loading branch information
Showing
10 changed files
with
782 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Run a V1 membership change that adds a single voter. | ||
|
||
# Bootstrap n1. | ||
add-nodes 1 voters=(1) index=2 | ||
---- | ||
INFO 1 switched to configuration voters=(1) | ||
INFO 1 became follower at term 0 | ||
INFO newRaft 1 [peers: [1], term: 0, commit: 2, applied: 2, lastindex: 2, lastterm: 1] | ||
|
||
campaign 1 | ||
---- | ||
INFO 1 is starting a new election at term 0 | ||
INFO 1 became candidate at term 1 | ||
INFO 1 received MsgVoteResp from 1 at term 1 | ||
INFO 1 became leader at term 1 | ||
|
||
# Add v2 (with an auto transition). | ||
propose-conf-change 1 v1=true | ||
v2 | ||
---- | ||
ok | ||
|
||
# Pull n2 out of thin air. | ||
add-nodes 1 | ||
---- | ||
INFO 2 switched to configuration voters=() | ||
INFO 2 became follower at term 0 | ||
INFO newRaft 2 [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0] | ||
|
||
# n1 commits the conf change using itself as commit quorum, immediately transitions into | ||
# the final config, and catches up n2. Note that it's using an EntryConfChange, not an | ||
# EntryConfChangeV2, so this is compatible with nodes that don't know about V2 conf changes. | ||
stabilize | ||
---- | ||
> 1 handling Ready | ||
INFO 1 switched to configuration voters=(1 2) | ||
Ready MustSync=true: | ||
Lead:1 State:StateLeader | ||
HardState Term:1 Vote:1 Commit:4 | ||
Entries: | ||
1/3 EntryNormal "" | ||
1/4 EntryConfChange v2 | ||
CommittedEntries: | ||
1/3 EntryNormal "" | ||
1/4 EntryConfChange v2 | ||
> 1 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
1->2 MsgApp Term:1 Log:1/3 Commit:4 Entries:[1/4 EntryConfChange v2] | ||
> delivering messages | ||
1->2 MsgApp Term:1 Log:1/3 Commit:4 Entries:[1/4 EntryConfChange v2] | ||
INFO 2 [term: 0] received a MsgApp message with higher term from 1 [term: 1] | ||
INFO 2 became follower at term 1 | ||
DEBUG 2 [logterm: 0, index: 3] rejected MsgApp [logterm: 1, index: 3] from 1 | ||
> 2 handling Ready | ||
Ready MustSync=true: | ||
Lead:1 State:StateFollower | ||
HardState Term:1 Commit:0 | ||
Messages: | ||
2->1 MsgAppResp Term:1 Log:0/3 Rejected (Hint: 0) | ||
> delivering messages | ||
2->1 MsgAppResp Term:1 Log:0/3 Rejected (Hint: 0) | ||
DEBUG 1 received MsgAppResp(MsgApp was rejected, lastindex: 0) from 2 for index 3 | ||
DEBUG 1 decreased progress of 2 to [StateProbe match=0 next=1] | ||
DEBUG 1 [firstindex: 3, commit: 4] sent snapshot[index: 4, term: 1] to 2 [StateProbe match=0 next=1] | ||
DEBUG 1 paused sending replication messages to 2 [StateSnapshot match=0 next=1 paused pendingSnap=4] | ||
> 1 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
1->2 MsgSnap Term:1 Log:0/0 Snapshot: Index:4 Term:1 ConfState:Voters:[1 2] VotersOutgoing:[] Learners:[] LearnersNext:[] AutoLeave:false | ||
> delivering messages | ||
1->2 MsgSnap Term:1 Log:0/0 Snapshot: Index:4 Term:1 ConfState:Voters:[1 2] VotersOutgoing:[] Learners:[] LearnersNext:[] AutoLeave:false | ||
INFO log [committed=0, applied=0, unstable.offset=1, len(unstable.Entries)=0] starts to restore snapshot [index: 4, term: 1] | ||
INFO 2 switched to configuration voters=(1 2) | ||
INFO 2 [commit: 4, lastindex: 4, lastterm: 1] restored snapshot [index: 4, term: 1] | ||
INFO 2 [commit: 4] restored snapshot [index: 4, term: 1] | ||
> 2 handling Ready | ||
Ready MustSync=false: | ||
HardState Term:1 Commit:4 | ||
Snapshot Index:4 Term:1 ConfState:Voters:[1 2] VotersOutgoing:[] Learners:[] LearnersNext:[] AutoLeave:false | ||
Messages: | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
> delivering messages | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
DEBUG 1 recovered from needing snapshot, resumed sending replication messages to 2 [StateSnapshot match=4 next=5 paused pendingSnap=4] | ||
> 1 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
1->2 MsgApp Term:1 Log:1/4 Commit:4 | ||
> delivering messages | ||
1->2 MsgApp Term:1 Log:1/4 Commit:4 | ||
> 2 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
> delivering messages | ||
2->1 MsgAppResp Term:1 Log:0/4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# We'll turn this back on after the boilerplate. | ||
log-level none | ||
---- | ||
ok | ||
|
||
# Run a V1 membership change that removes the leader. | ||
# Bootstrap n1, n2, n3. | ||
add-nodes 3 voters=(1,2,3) index=2 | ||
---- | ||
ok | ||
|
||
campaign 1 | ||
---- | ||
ok | ||
|
||
stabilize | ||
---- | ||
ok (quiet) | ||
|
||
log-level debug | ||
---- | ||
ok | ||
|
||
# Remove n1. | ||
propose-conf-change 1 v1=true | ||
r1 | ||
---- | ||
ok | ||
|
||
stabilize | ||
---- | ||
> 1 handling Ready | ||
Ready MustSync=true: | ||
Entries: | ||
1/4 EntryConfChange r1 | ||
Messages: | ||
1->2 MsgApp Term:1 Log:1/3 Commit:3 Entries:[1/4 EntryConfChange r1] | ||
1->3 MsgApp Term:1 Log:1/3 Commit:3 Entries:[1/4 EntryConfChange r1] | ||
> delivering messages | ||
1->2 MsgApp Term:1 Log:1/3 Commit:3 Entries:[1/4 EntryConfChange r1] | ||
> delivering messages | ||
1->3 MsgApp Term:1 Log:1/3 Commit:3 Entries:[1/4 EntryConfChange r1] | ||
> 2 handling Ready | ||
Ready MustSync=true: | ||
Entries: | ||
1/4 EntryConfChange r1 | ||
Messages: | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
> 3 handling Ready | ||
Ready MustSync=true: | ||
Entries: | ||
1/4 EntryConfChange r1 | ||
Messages: | ||
3->1 MsgAppResp Term:1 Log:0/4 | ||
> delivering messages | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
3->1 MsgAppResp Term:1 Log:0/4 | ||
> 1 handling Ready | ||
INFO 1 switched to configuration voters=(2 3) | ||
Ready MustSync=false: | ||
HardState Term:1 Vote:1 Commit:4 | ||
CommittedEntries: | ||
1/4 EntryConfChange r1 | ||
Messages: | ||
1->2 MsgApp Term:1 Log:1/4 Commit:4 | ||
1->3 MsgApp Term:1 Log:1/4 Commit:4 | ||
> delivering messages | ||
1->2 MsgApp Term:1 Log:1/4 Commit:4 | ||
> delivering messages | ||
1->3 MsgApp Term:1 Log:1/4 Commit:4 | ||
> 2 handling Ready | ||
INFO 2 switched to configuration voters=(2 3) | ||
Ready MustSync=false: | ||
HardState Term:1 Vote:1 Commit:4 | ||
CommittedEntries: | ||
1/4 EntryConfChange r1 | ||
Messages: | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
> 3 handling Ready | ||
INFO 3 switched to configuration voters=(2 3) | ||
Ready MustSync=false: | ||
HardState Term:1 Vote:1 Commit:4 | ||
CommittedEntries: | ||
1/4 EntryConfChange r1 | ||
Messages: | ||
3->1 MsgAppResp Term:1 Log:0/4 | ||
> delivering messages | ||
2->1 MsgAppResp Term:1 Log:0/4 | ||
3->1 MsgAppResp Term:1 Log:0/4 | ||
|
||
status 1 | ||
---- | ||
2: StateReplicate match=4 next=5 | ||
3: StateReplicate match=4 next=5 | ||
|
||
# TODO(tbg): the leader now drops any proposals, but if it has any other | ||
# uncommitted proposals in its log already, it will likely try to distribute | ||
# them which could be buggy. Test that. | ||
propose-conf-change 1 v1=true | ||
v1 | ||
---- | ||
raft proposal dropped | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.