Skip to content

Commit 7bef1e1

Browse files
committed
kvserver: inline clearRangeData in RHS clearing func
Epic: none Release note: none
1 parent 13091e1 commit 7bef1e1

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

pkg/kv/kvserver/kvstorage/destroy.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ func RemoveStaleRHSFromSplit(
236236
rangeID roachpb.RangeID,
237237
keys roachpb.RSpan,
238238
) error {
239-
return clearRangeData(ctx, rangeID, reader, writer, clearRangeDataOptions{
239+
for _, span := range rditer.Select(rangeID, rditer.SelectOpts{
240240
// Since the RHS replica is uninitalized, we know there isn't anything in
241-
// the two replicated spans below, before the current batch. Setting these
241+
// the replicated spans below, before the current batch. Setting these
242242
// options will in effect only clear the writes to the RHS replicated state
243243
// staged in the batch.
244-
clearReplicatedBySpan: keys,
245-
clearReplicatedByRangeID: true,
244+
ReplicatedByRangeID: true,
245+
Ranged: rditer.SelectAllRanged(keys),
246246
// TODO(tbg): we don't actually want to touch the raft state of the RHS
247247
// replica since it's absent or a more recent one than in the split. Now
248248
// that we have a bool targeting unreplicated RangeID-local keys, we can set
@@ -255,8 +255,15 @@ func RemoveStaleRHSFromSplit(
255255
// [^1]: https://github.com/cockroachdb/cockroach/blob/f263a765d750e41f2701da0a923a6e92d09159fa/pkg/kv/kvserver/batcheval/cmd_end_transaction.go#L1109-L1149
256256
//
257257
// See also: https://github.com/cockroachdb/cockroach/issues/94933
258-
clearUnreplicatedByRangeID: true,
259-
})
258+
UnreplicatedByRangeID: true,
259+
}) {
260+
if err := storage.ClearRangeWithHeuristic(
261+
ctx, reader, writer, span.Key, span.EndKey, ClearRangeThresholdPointKeys(),
262+
); err != nil {
263+
return err
264+
}
265+
}
266+
return nil
260267
}
261268

262269
// TestingForceClearRange changes the value of ClearRangeThresholdPointKeys to

pkg/kv/kvserver/rditer/select.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ type SelectRangedOptions struct {
5353
UserKeys bool
5454
}
5555

56+
// SelectAllRanged returns SelectRangeOptions that covers all span-based
57+
// replicated keys in the given range.
58+
func SelectAllRanged(span roachpb.RSpan) SelectRangedOptions {
59+
return SelectRangedOptions{
60+
RSpan: span,
61+
SystemKeys: true,
62+
LockTable: true,
63+
UserKeys: true,
64+
}
65+
}
66+
5667
// SelectOpts configures which spans for a Replica to return from Select.
5768
// A Replica comprises replicated (i.e. belonging to the state machine) spans
5869
// and unreplicated spans, and depending on external circumstances one may want

0 commit comments

Comments
 (0)