-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate Staging suffrage and Promote command #486
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,16 @@ var nextConfigurationTests = []struct { | |
// AddStaging: was Nonvoter. | ||
{oneOfEach, AddStaging, 3, "{[{Voter id1 addr1x} {Staging id2 addr2x} {Voter id3 addr3}]}"}, | ||
|
||
// AddVoter: was missing. | ||
{Configuration{}, AddVoter, 1, "{[{Voter id1 addr1}]}"}, | ||
{singleServer, AddVoter, 2, "{[{Voter id1 addr1x} {Voter id2 addr2}]}"}, | ||
// AddVoter: was Voter. | ||
{singleServer, AddVoter, 1, "{[{Voter id1 addr1}]}"}, | ||
// AddVoter: was Staging. | ||
{oneOfEach, AddVoter, 2, "{[{Voter id1 addr1x} {Voter id2 addr2} {Nonvoter id3 addr3x}]}"}, | ||
// AddVoter: was Nonvoter. | ||
{oneOfEach, AddVoter, 3, "{[{Voter id1 addr1x} {Staging id2 addr2x} {Voter id3 addr3}]}"}, | ||
|
||
Comment on lines
+182
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just copy/paste of the |
||
// AddNonvoter: was missing. | ||
{singleServer, AddNonvoter, 2, "{[{Voter id1 addr1x} {Nonvoter id2 addr2}]}"}, | ||
// AddNonvoter: was Voter. | ||
|
@@ -238,7 +248,7 @@ func TestConfiguration_nextConfiguration_table(t *testing.T) { | |
func TestConfiguration_nextConfiguration_prevIndex(t *testing.T) { | ||
// Stale prevIndex. | ||
req := configurationChangeRequest{ | ||
command: AddStaging, | ||
command: AddVoter, | ||
serverID: ServerID("id1"), | ||
serverAddress: ServerAddress("addr1"), | ||
prevIndex: 1, | ||
|
@@ -250,7 +260,7 @@ func TestConfiguration_nextConfiguration_prevIndex(t *testing.T) { | |
|
||
// Current prevIndex. | ||
req = configurationChangeRequest{ | ||
command: AddStaging, | ||
command: AddVoter, | ||
serverID: ServerID("id2"), | ||
serverAddress: ServerAddress("addr2"), | ||
prevIndex: 2, | ||
|
@@ -262,7 +272,7 @@ func TestConfiguration_nextConfiguration_prevIndex(t *testing.T) { | |
|
||
// Zero prevIndex. | ||
req = configurationChangeRequest{ | ||
command: AddStaging, | ||
command: AddVoter, | ||
serverID: ServerID("id3"), | ||
serverAddress: ServerAddress("addr3"), | ||
prevIndex: 0, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1370,9 +1370,7 @@ func (r *Raft) appendEntries(rpc RPC, a *AppendEntriesRequest) { | |
return | ||
} | ||
if entry.Term != storeEntry.Term { | ||
r.logger.Warn("clearing log suffix", | ||
"from", entry.Index, | ||
"to", lastLogIdx) | ||
r.logger.Warn("clearing log suffix", "from", entry.Index, "to", lastLogIdx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated cleanup I had done while reading the code. This log line fits pretty easily on one line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen this done stylistically to better show the pairing of variadic args (which I think reads better but this one is short enough not to be confusing) |
||
if err := r.logs.DeleteRange(entry.Index, lastLogIdx); err != nil { | ||
r.logger.Error("failed to clear log suffix", "error", err) | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By keeping the constant value 0 it should be safe to upgrade raft. Because any existing clients will send a 0 in the RPC message, and new clients will also send a 0 using the new
AddVoter
constant.