@@ -179,20 +179,28 @@ func DestroyReplica(
179179// (and the corresponding system and lock table keys). The latter are inherited
180180// by the subsuming range.
181181//
182+ // The forceSortedKeys flag, if true, forces the writes to be generated in the
183+ // sorted order of keys. This is to support feeding the writes from this
184+ // function to SSTables, in the snapshot ingestion path.
185+ //
182186// Returns SelectOpts which can be used to reflect on the key spans that this
183187// function clears.
184188// TODO(pav-kv): get rid of SelectOpts.
185189func SubsumeReplica (
186- ctx context.Context , reader storage.Reader , writer storage.Writer , info DestroyReplicaInfo ,
190+ ctx context.Context ,
191+ reader storage.Reader ,
192+ writer storage.Writer ,
193+ info DestroyReplicaInfo ,
194+ forceSortedKeys bool ,
187195) (rditer.SelectOpts , error ) {
188- // NB: set MustUseClearRange to true because this call is used for generating
189- // SSTables when ingesting a snapshot, which requires Clears and Puts to be
190- // written in key order. DestroyReplica sets RangeTombstoneKey after clearing
191- // the unreplicated span which may contain higher keys.
196+ // NB: if required, set MustUseClearRange to true. This call can be used for
197+ // generating SSTables when ingesting a snapshot, which requires Clears and
198+ // Puts to be written in key order. DestroyReplica sets RangeTombstoneKey
199+ // after clearing the unreplicated span which may contain higher keys.
192200 opts := ClearRangeDataOptions {
193201 ClearReplicatedByRangeID : true ,
194202 ClearUnreplicatedByRangeID : true ,
195- MustUseClearRange : true ,
203+ MustUseClearRange : forceSortedKeys ,
196204 }
197205 return rditer.SelectOpts {
198206 ReplicatedByRangeID : opts .ClearReplicatedByRangeID ,
0 commit comments