kvserver: improve locking around replica destruction #64459
Labels
A-kv-replication
Relating to Raft, consensus, and coordination.
C-cleanup
Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.
The
Replica.mu.destroyStatus
field is used to signal atomic replica destruction. To update this, we often need to take out a bunch of locks -- typicallyraftMu
,readOnlyCmdMu
, andmu
-- in a specific order:cockroach/pkg/kv/kvserver/store.go
Lines 471 to 476 in f8e1c90
This is tedious and error-prone. We should revisit this to see if it can be improved, at least in terms of ergonomics and safety. We should also use convenience methods on the replica to interact with
destroyStatus
, named by the locks that need to be held (e.g.Replica.destroyRaftMuReadOnlyCmdMuMuLocked
😐), and assert that the proper locks are in fact held withMutex.AssertHeld()
orMutex.AssertRHeld()
.See also #64324 for some discussion.
Jira issue: CRDB-7066
The text was updated successfully, but these errors were encountered: