Skip to content

Commit 19c1452

Browse files
committed
kvstorage: unexport ClearRangeData and opts
This is now an implementation detail of the package subject to change. Epic: none Release note: none
1 parent 84f9ed3 commit 19c1452

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

pkg/kv/kvserver/kvstorage/destroy.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,53 +40,53 @@ const (
4040
MergedTombstoneReplicaID roachpb.ReplicaID = math.MaxInt32
4141
)
4242

43-
// ClearRangeDataOptions specify which parts of a Replica are to be destroyed.
44-
type ClearRangeDataOptions struct {
45-
// ClearReplicatedByRangeID indicates that replicated RangeID-based keys
43+
// clearRangeDataOptions specify which parts of a Replica are to be destroyed.
44+
type clearRangeDataOptions struct {
45+
// clearReplicatedByRangeID indicates that replicated RangeID-based keys
4646
// (abort span, etc) should be removed.
47-
ClearReplicatedByRangeID bool
48-
// ClearUnreplicatedByRangeID indicates that unreplicated RangeID-based keys
47+
clearReplicatedByRangeID bool
48+
// clearUnreplicatedByRangeID indicates that unreplicated RangeID-based keys
4949
// (logstore state incl. HardState, etc) should be removed.
50-
ClearUnreplicatedByRangeID bool
51-
// ClearReplicatedBySpan causes the state machine data (i.e. the replicated state
50+
clearUnreplicatedByRangeID bool
51+
// clearReplicatedBySpan causes the state machine data (i.e. the replicated state
5252
// for the given RSpan) that is key-addressable (i.e. range descriptor, user keys,
5353
// locks) to be removed. No data is removed if this is the zero span.
54-
ClearReplicatedBySpan roachpb.RSpan
54+
clearReplicatedBySpan roachpb.RSpan
5555

56-
// If MustUseClearRange is true, a Pebble range tombstone will always be used
56+
// If mustUseClearRange is true, a Pebble range tombstone will always be used
5757
// to clear the key spans (unless empty). This is typically used when we need
5858
// to write additional keys to an SST after this clear, e.g. a replica
5959
// tombstone, since keys must be written in order. When this is false, a
6060
// heuristic will be used instead.
61-
MustUseClearRange bool
61+
mustUseClearRange bool
6262
}
6363

64-
// ClearRangeData clears the data associated with a range descriptor selected
64+
// clearRangeData clears the data associated with a range descriptor selected
6565
// by the provided options.
6666
//
6767
// TODO(tbg): could rename this to XReplica. The use of "Range" in both the
6868
// "CRDB Range" and "storage.ClearRange" context in the setting of this method could
6969
// be confusing.
70-
func ClearRangeData(
70+
func clearRangeData(
7171
ctx context.Context,
7272
rangeID roachpb.RangeID,
7373
reader storage.Reader,
7474
writer storage.Writer,
75-
opts ClearRangeDataOptions,
75+
opts clearRangeDataOptions,
7676
) error {
7777
keySpans := rditer.Select(rangeID, rditer.SelectOpts{
7878
Ranged: rditer.SelectRangedOptions{
79-
RSpan: opts.ClearReplicatedBySpan,
79+
RSpan: opts.clearReplicatedBySpan,
8080
SystemKeys: true,
8181
LockTable: true,
8282
UserKeys: true,
8383
},
84-
ReplicatedByRangeID: opts.ClearReplicatedByRangeID,
85-
UnreplicatedByRangeID: opts.ClearUnreplicatedByRangeID,
84+
ReplicatedByRangeID: opts.clearReplicatedByRangeID,
85+
UnreplicatedByRangeID: opts.clearUnreplicatedByRangeID,
8686
})
8787

8888
pointKeyThreshold := ClearRangeThresholdPointKeys
89-
if opts.MustUseClearRange {
89+
if opts.mustUseClearRange {
9090
pointKeyThreshold = 1
9191
}
9292

@@ -139,10 +139,10 @@ func DestroyReplica(
139139
info DestroyReplicaInfo,
140140
next roachpb.ReplicaID,
141141
) error {
142-
return destroyReplicaImpl(ctx, reader, writer, info, next, ClearRangeDataOptions{
143-
ClearReplicatedByRangeID: true,
144-
ClearUnreplicatedByRangeID: true,
145-
ClearReplicatedBySpan: info.Keys,
142+
return destroyReplicaImpl(ctx, reader, writer, info, next, clearRangeDataOptions{
143+
clearReplicatedByRangeID: true,
144+
clearUnreplicatedByRangeID: true,
145+
clearReplicatedBySpan: info.Keys,
146146
})
147147
}
148148

@@ -152,7 +152,7 @@ func destroyReplicaImpl(
152152
writer storage.Writer,
153153
info DestroyReplicaInfo,
154154
next roachpb.ReplicaID,
155-
opts ClearRangeDataOptions,
155+
opts clearRangeDataOptions,
156156
) error {
157157
if next <= info.ReplicaID {
158158
return errors.AssertionFailedf("%v must not survive its own tombstone", info.FullReplicaID)
@@ -174,7 +174,7 @@ func destroyReplicaImpl(
174174
}
175175

176176
_ = DestroyReplicaTODO // 2.1 + 2.2 + 3.1
177-
if err := ClearRangeData(ctx, info.RangeID, reader, writer, opts); err != nil {
177+
if err := clearRangeData(ctx, info.RangeID, reader, writer, opts); err != nil {
178178
return err
179179
}
180180
// Save a tombstone to ensure that replica IDs never get reused.
@@ -206,14 +206,14 @@ func SubsumeReplica(
206206
// generating SSTables when ingesting a snapshot, which requires Clears and
207207
// Puts to be written in key order. DestroyReplica sets RangeTombstoneKey
208208
// after clearing the unreplicated span which may contain higher keys.
209-
opts := ClearRangeDataOptions{
210-
ClearReplicatedByRangeID: true,
211-
ClearUnreplicatedByRangeID: true,
212-
MustUseClearRange: forceSortedKeys,
209+
opts := clearRangeDataOptions{
210+
clearReplicatedByRangeID: true,
211+
clearUnreplicatedByRangeID: true,
212+
mustUseClearRange: forceSortedKeys,
213213
}
214214
return rditer.SelectOpts{
215-
ReplicatedByRangeID: opts.ClearReplicatedByRangeID,
216-
UnreplicatedByRangeID: opts.ClearUnreplicatedByRangeID,
215+
ReplicatedByRangeID: opts.clearReplicatedByRangeID,
216+
UnreplicatedByRangeID: opts.clearUnreplicatedByRangeID,
217217
}, destroyReplicaImpl(ctx, reader, writer, info, MergedTombstoneReplicaID, opts)
218218
}
219219

@@ -231,13 +231,13 @@ func RemoveStaleRHSFromSplit(
231231
rangeID roachpb.RangeID,
232232
keys roachpb.RSpan,
233233
) error {
234-
return ClearRangeData(ctx, rangeID, reader, writer, ClearRangeDataOptions{
234+
return clearRangeData(ctx, rangeID, reader, writer, clearRangeDataOptions{
235235
// Since the RHS replica is uninitalized, we know there isn't anything in
236236
// the two replicated spans below, before the current batch. Setting these
237237
// options will in effect only clear the writes to the RHS replicated state
238238
// staged in the batch.
239-
ClearReplicatedBySpan: keys,
240-
ClearReplicatedByRangeID: true,
239+
clearReplicatedBySpan: keys,
240+
clearReplicatedByRangeID: true,
241241
// TODO(tbg): we don't actually want to touch the raft state of the RHS
242242
// replica since it's absent or a more recent one than in the split. Now
243243
// that we have a bool targeting unreplicated RangeID-local keys, we can set
@@ -250,6 +250,6 @@ func RemoveStaleRHSFromSplit(
250250
// [^1]: https://github.com/cockroachdb/cockroach/blob/f263a765d750e41f2701da0a923a6e92d09159fa/pkg/kv/kvserver/batcheval/cmd_end_transaction.go#L1109-L1149
251251
//
252252
// See also: https://github.com/cockroachdb/cockroach/issues/94933
253-
ClearUnreplicatedByRangeID: true,
253+
clearUnreplicatedByRangeID: true,
254254
})
255255
}

0 commit comments

Comments
 (0)