Skip to content

Commit

Permalink
Merge pull request #103877 from tbg/backport22.2-103827
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg authored May 25, 2023
2 parents 39a6c89 + ee83cfe commit 4ce9320
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
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 @@ -23,6 +23,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"
"go.etcd.io/etcd/raft/v3/tracker"
)

func (r *Replica) quiesceLocked(ctx context.Context, lagging laggingReplicaSet) {
Expand Down Expand Up @@ -383,7 +384,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 @@ -395,8 +396,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 @@ -10202,9 +10202,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 @@ -10298,6 +10298,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

0 comments on commit 4ce9320

Please sign in to comment.