Skip to content
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

kvserver: don't quiesce with follower in StateProbe #103827

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/kv/kvserver/replica_raft_quiesce.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"go.etcd.io/raft/v3"
"go.etcd.io/raft/v3/raftpb"
"go.etcd.io/raft/v3/tracker"
)

// quiesceAfterTicks is the number of ticks without proposals after which ranges
Expand Down Expand Up @@ -420,7 +421,7 @@ func shouldReplicaQuiesce(
rep.ReplicaID, progress)
}
return nil, nil, false
} else if progress.Match != status.Applied {
} else if progress.Match != status.Applied || progress.State != tracker.StateReplicate {
// Skip any node in the descriptor which is not live. Instead, add
// the node to the set of replicas lagging the quiescence index.
if l, ok := livenessMap[rep.NodeID]; ok && !l.IsLive {
Expand All @@ -432,8 +433,8 @@ func shouldReplicaQuiesce(
continue
}
if log.V(4) {
log.Infof(ctx, "not quiescing: replica %d match (%d) != applied (%d)",
rep.ReplicaID, progress.Match, status.Applied)
log.Infof(ctx, "not quiescing: replica %d match (%d) != applied (%d) or state %s not admissible",
rep.ReplicaID, progress.Match, status.Applied, progress.State)
}
return nil, nil, false
}
Expand Down
12 changes: 9 additions & 3 deletions pkg/kv/kvserver/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10065,9 +10065,9 @@ func TestShouldReplicaQuiesce(t *testing.T) {
LeadTransferee: 0,
},
Progress: map[uint64]tracker.Progress{
1: {Match: logIndex},
2: {Match: logIndex},
3: {Match: logIndex},
1: {Match: logIndex, State: tracker.StateReplicate},
2: {Match: logIndex, State: tracker.StateReplicate},
3: {Match: logIndex, State: tracker.StateReplicate},
},
},
lastIndex: logIndex,
Expand Down Expand Up @@ -10209,6 +10209,12 @@ func TestShouldReplicaQuiesce(t *testing.T) {
q.raftReady = true
return q
})
test(false, func(q *testQuiescer) *testQuiescer {
pr := q.status.Progress[2]
pr.State = tracker.StateProbe
q.status.Progress[2] = pr
return q
})
// Create a mismatch between the raft progress replica IDs and the
// replica IDs in the range descriptor.
for i := 0; i < 3; i++ {
Expand Down