Skip to content

Commit 36b934c

Browse files
committed
kvserver: move options generation down the stack
After this, there is only one user of clearRangeDataOptions and clearRangeData, which allows us removing this call in the next commit. Epic: none Release note: none
1 parent 7bef1e1 commit 36b934c

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

pkg/kv/kvserver/kvstorage/destroy.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ func DestroyReplica(
144144
info DestroyReplicaInfo,
145145
next roachpb.ReplicaID,
146146
) error {
147-
return destroyReplicaImpl(ctx, reader, writer, info, next, clearRangeDataOptions{
148-
clearReplicatedByRangeID: true,
149-
clearUnreplicatedByRangeID: true,
150-
clearReplicatedBySpan: info.Keys,
151-
})
147+
return destroyReplicaImpl(ctx, reader, writer, info, next, false /* forceSortedKeys */)
152148
}
153149

154150
func destroyReplicaImpl(
@@ -157,7 +153,7 @@ func destroyReplicaImpl(
157153
writer storage.Writer,
158154
info DestroyReplicaInfo,
159155
next roachpb.ReplicaID,
160-
opts clearRangeDataOptions,
156+
forceSortedKeys bool,
161157
) error {
162158
if next <= info.ReplicaID {
163159
return errors.AssertionFailedf("%v must not survive its own tombstone", info.FullReplicaID)
@@ -179,7 +175,16 @@ func destroyReplicaImpl(
179175
}
180176

181177
_ = DestroyReplicaTODO // 2.1 + 2.2 + 3.1
182-
if err := clearRangeData(ctx, info.RangeID, reader, writer, opts); err != nil {
178+
// NB: if required, set mustUseClearRange to true. This call can be used for
179+
// generating SSTables when ingesting a snapshot, which requires Clears and
180+
// Puts to be written in key order. DestroyReplica sets RangeTombstoneKey
181+
// after clearing the unreplicated span which may contain higher keys.
182+
if err := clearRangeData(ctx, info.RangeID, reader, writer, clearRangeDataOptions{
183+
clearReplicatedByRangeID: true,
184+
clearUnreplicatedByRangeID: true,
185+
clearReplicatedBySpan: info.Keys,
186+
mustUseClearRange: forceSortedKeys,
187+
}); err != nil {
183188
return err
184189
}
185190
// Save a tombstone to ensure that replica IDs never get reused.
@@ -207,19 +212,12 @@ func SubsumeReplica(
207212
info DestroyReplicaInfo,
208213
forceSortedKeys bool,
209214
) (rditer.SelectOpts, error) {
210-
// NB: if required, set MustUseClearRange to true. This call can be used for
211-
// generating SSTables when ingesting a snapshot, which requires Clears and
212-
// Puts to be written in key order. DestroyReplica sets RangeTombstoneKey
213-
// after clearing the unreplicated span which may contain higher keys.
214-
opts := clearRangeDataOptions{
215-
clearReplicatedByRangeID: true,
216-
clearUnreplicatedByRangeID: true,
217-
mustUseClearRange: forceSortedKeys,
218-
}
215+
// Forget about the user keys.
216+
info.Keys = roachpb.RSpan{}
219217
return rditer.SelectOpts{
220-
ReplicatedByRangeID: opts.clearReplicatedByRangeID,
221-
UnreplicatedByRangeID: opts.clearUnreplicatedByRangeID,
222-
}, destroyReplicaImpl(ctx, reader, writer, info, MergedTombstoneReplicaID, opts)
218+
ReplicatedByRangeID: true,
219+
UnreplicatedByRangeID: true,
220+
}, destroyReplicaImpl(ctx, reader, writer, info, MergedTombstoneReplicaID, forceSortedKeys)
223221
}
224222

225223
// RemoveStaleRHSFromSplit removes all data for the RHS replica of a split. This

0 commit comments

Comments
 (0)