Skip to content

Commit 325f098

Browse files
committed
kvserver: drop removeReplicaRaftMuLocked opts
All callers use the same parameter, so we can inline it. After this commit, removeInitializedReplicaRaftMuLocked is the only remaining call accepting RemoveOptions, which makes the scope of these options clearer. Epic: none Release note: none
1 parent 3abfe27 commit 325f098

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

pkg/kv/kvserver/store_create_replica.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ func (s *Store) tryGetReplica(
116116
}
117117

118118
repl.mu.RUnlock()
119-
if err := s.removeReplicaRaftMuLocked(ctx, repl, id.ReplicaID, "superseded by newer Replica", RemoveOptions{
120-
DestroyData: true,
121-
}); err != nil {
119+
if err := s.removeReplicaRaftMuLocked(
120+
ctx, repl, id.ReplicaID, "superseded by newer Replica",
121+
); err != nil {
122122
log.Fatalf(ctx, "failed to remove replica: %v", err)
123123
}
124124
repl.raftMu.Unlock()

pkg/kv/kvserver/store_raft.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,7 @@ func (s *Store) HandleRaftResponse(
638638

639639
repl.mu.Unlock()
640640
nextReplicaID := tErr.ReplicaID + 1
641-
return s.removeReplicaRaftMuLocked(ctx, repl, nextReplicaID, "received ReplicaTooOldError", RemoveOptions{
642-
DestroyData: true,
643-
})
641+
return s.removeReplicaRaftMuLocked(ctx, repl, nextReplicaID, "received ReplicaTooOldError")
644642
case *kvpb.RaftGroupDeletedError:
645643
if replErr != nil {
646644
// RangeNotFoundErrors are expected here; nothing else is.

pkg/kv/kvserver/store_remove_replica.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,15 @@ func (s *Store) RemoveReplica(
4545
return err
4646
}
4747

48-
// removeReplicaRaftMuLocked removes the passed replica. If the replica is
49-
// initialized the RemoveOptions will be consulted.
48+
// removeReplicaRaftMuLocked removes the passed replica.
5049
func (s *Store) removeReplicaRaftMuLocked(
51-
ctx context.Context,
52-
rep *Replica,
53-
nextReplicaID roachpb.ReplicaID,
54-
reason redact.SafeString,
55-
opts RemoveOptions,
50+
ctx context.Context, rep *Replica, nextReplicaID roachpb.ReplicaID, reason redact.SafeString,
5651
) error {
5752
rep.raftMu.AssertHeld()
5853
if rep.IsInitialized() {
59-
if opts.InsertPlaceholder {
60-
return errors.Errorf("InsertPlaceholder unsupported in removeReplicaRaftMuLocked")
61-
}
62-
_, err := s.removeInitializedReplicaRaftMuLocked(ctx, rep, nextReplicaID, reason, opts)
63-
return errors.Wrap(err,
64-
"failed to remove replica")
54+
_, err := s.removeInitializedReplicaRaftMuLocked(
55+
ctx, rep, nextReplicaID, reason, RemoveOptions{DestroyData: true})
56+
return errors.Wrap(err, "failed to remove replica")
6557
}
6658
s.removeUninitializedReplicaRaftMuLocked(ctx, rep, nextReplicaID)
6759
return nil

0 commit comments

Comments
 (0)