Skip to content

Commit

Permalink
kvserver: remove the replica.mu.draining field
Browse files Browse the repository at this point in the history
It was only used in one rando place. Generally everybody looks at the
store's draing status.

Release note: None
  • Loading branch information
andreimatei committed Oct 26, 2020
1 parent dd92e33 commit af594d8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
7 changes: 1 addition & 6 deletions pkg/kv/kvserver/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,6 @@ type Replica struct {
// depending on which lock is being held.
stateLoader stateloader.StateLoader

// draining specifies whether this replica is draining. Raft leadership
// transfers due to a lease change will be attempted even if the target does
// not have all the log entries.
draining bool

// cachedProtectedTS provides the state of the protected timestamp
// subsystem as used on the request serving path to determine the effective
// gc threshold given the current TTL when using strict GC enforcement.
Expand Down Expand Up @@ -1606,7 +1601,7 @@ func (r *Replica) maybeTransferRaftLeadershipToLeaseholderLocked(ctx context.Con
}
lhReplicaID := uint64(lease.Replica.ReplicaID)
lhProgress, ok := raftStatus.Progress[lhReplicaID]
if (ok && lhProgress.Match >= raftStatus.Commit) || r.mu.draining {
if (ok && lhProgress.Match >= raftStatus.Commit) || r.store.IsDraining() {
log.VEventf(ctx, 1, "transferring raft leadership to replica ID %v", lhReplicaID)
r.store.metrics.RangeRaftLeaderTransfers.Inc(1)
r.mu.internalRaftGroup.TransferLeader(lhReplicaID)
Expand Down
10 changes: 0 additions & 10 deletions pkg/kv/kvserver/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,6 @@ func (s *Store) AnnotateCtx(ctx context.Context) context.Context {
func (s *Store) SetDraining(drain bool, reporter func(int, redact.SafeString)) {
s.draining.Store(drain)
if !drain {
newStoreReplicaVisitor(s).Visit(func(r *Replica) bool {
r.mu.Lock()
r.mu.draining = false
r.mu.Unlock()
return true
})
return
}

Expand Down Expand Up @@ -1110,10 +1104,6 @@ func (s *Store) SetDraining(drain bool, reporter func(int, redact.SafeString)) {
default:
}

r.mu.Lock()
r.mu.draining = true
r.mu.Unlock()

var drainingLease roachpb.Lease
for {
var llHandle *leaseRequestHandle
Expand Down

0 comments on commit af594d8

Please sign in to comment.