forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from cockroachdb/erik/22.2-probe-state-heartbeat
crdb-release-22.2: Move from StatePause->StateReplicate on heartbeat response when possible
- Loading branch information
Showing
6 changed files
with
201 additions
and
38 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
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
30 changes: 30 additions & 0 deletions
30
raft/rafttest/interaction_env_handler_report_unreachable.go
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,30 @@ | ||
// Copyright 2023 The etcd Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package rafttest | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/cockroachdb/datadriven" | ||
) | ||
|
||
func (env *InteractionEnv) handleReportUnreachable(t *testing.T, d datadriven.TestData) error { | ||
sl := nodeIdxs(t, d) | ||
if len(sl) != 2 { | ||
return errors.New("must specify exactly two node indexes: node on which to report, and reported node") | ||
} | ||
env.Nodes[sl[0]].ReportUnreachable(env.Nodes[sl[1]].Config.ID) | ||
return nil | ||
} |
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,90 @@ | ||
# This test checks that if a fully caught-up follower transitions | ||
# into StateProbe (for example due to a call to ReportUnreachable), the | ||
# leader will react to a subsequent heartbeat response from the probing | ||
# follower by sending an empty MsgApp, the response of which restores | ||
# StateReplicate for the follower. In other words, we don't end up in | ||
# a stable state with a fully caught up follower in StateProbe. | ||
|
||
# Turn off output during the setup of the test. | ||
log-level none | ||
---- | ||
ok | ||
|
||
add-nodes 3 voters=(1,2,3) index=10 | ||
---- | ||
ok | ||
|
||
campaign 1 | ||
---- | ||
ok | ||
|
||
stabilize | ||
---- | ||
ok (quiet) | ||
|
||
log-level debug | ||
---- | ||
ok | ||
|
||
status 1 | ||
---- | ||
1: StateReplicate match=11 next=12 inactive | ||
2: StateReplicate match=11 next=12 | ||
3: StateReplicate match=11 next=12 | ||
|
||
# On the first replica, report the second one as not reachable. | ||
report-unreachable 1 2 | ||
---- | ||
DEBUG 1 failed to send message to 2 because it is unreachable [StateProbe match=11 next=12] | ||
|
||
status 1 | ||
---- | ||
1: StateReplicate match=11 next=12 inactive | ||
2: StateProbe match=11 next=12 | ||
3: StateReplicate match=11 next=12 | ||
|
||
tick-heartbeat 1 | ||
---- | ||
ok | ||
|
||
# Heartbeat -> HeartbeatResp -> MsgApp -> MsgAppResp -> StateReplicate. | ||
stabilize | ||
---- | ||
> 1 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
1->2 MsgHeartbeat Term:1 Log:0/0 Commit:11 | ||
1->3 MsgHeartbeat Term:1 Log:0/0 Commit:11 | ||
> 2 receiving messages | ||
1->2 MsgHeartbeat Term:1 Log:0/0 Commit:11 | ||
> 3 receiving messages | ||
1->3 MsgHeartbeat Term:1 Log:0/0 Commit:11 | ||
> 2 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
2->1 MsgHeartbeatResp Term:1 Log:0/0 | ||
> 3 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
3->1 MsgHeartbeatResp Term:1 Log:0/0 | ||
> 1 receiving messages | ||
2->1 MsgHeartbeatResp Term:1 Log:0/0 | ||
3->1 MsgHeartbeatResp Term:1 Log:0/0 | ||
> 1 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
1->2 MsgApp Term:1 Log:1/11 Commit:11 | ||
> 2 receiving messages | ||
1->2 MsgApp Term:1 Log:1/11 Commit:11 | ||
> 2 handling Ready | ||
Ready MustSync=false: | ||
Messages: | ||
2->1 MsgAppResp Term:1 Log:0/11 | ||
> 1 receiving messages | ||
2->1 MsgAppResp Term:1 Log:0/11 | ||
|
||
status 1 | ||
---- | ||
1: StateReplicate match=11 next=12 inactive | ||
2: StateReplicate match=11 next=12 | ||
3: StateReplicate match=11 next=12 |