@@ -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
0 commit comments