@@ -414,6 +414,28 @@ func (r *Replica) updateRangeInfo(ctx context.Context, desc *roachpb.RangeDescri
414
414
return nil
415
415
}
416
416
417
+ // applySnapshotTODO is the plan for splitting snapshot application into
418
+ // cross-engine writes.
419
+ //
420
+ // 1. Log engine write (durable):
421
+ // 1.1. HardState, RaftTruncatedState for new LogID. Log is empty.
422
+ // 1.2. WAG node with the state machine mutation (2).
423
+ //
424
+ // 2. State machine mutation:
425
+ // 2.1. For subsumed, clear RangeID-local un-/replicated state.
426
+ // 2.2. For subsumed, write RangeTombstone with max NextReplicaID / LogID.
427
+ // 2.3. Clear MVCC keyspace for (this + subsumed).
428
+ // 2.4. Ingest snapshot SSTs.
429
+ // 2.5. Update RaftReplicaID with the new LogID.
430
+ //
431
+ // 3. Log engine GC (after state machine mutation 2 is durably applied):
432
+ // 3.1. Remove previous LogID.
433
+ // 3.2. For each subsumed, remove the last LogID.
434
+ //
435
+ // TODO(sep-raft-log): support the status quo in which 1+2+3 is written
436
+ // atomically, and 1.2 is not written.
437
+ const applySnapshotTODO = 0
438
+
417
439
// applySnapshotRaftMuLocked updates the replica and its store based on the given
418
440
// (non-empty) snapshot and associated HardState. All snapshots must pass
419
441
// through Raft for correctness, i.e. the parameters to this method must be
@@ -577,6 +599,7 @@ func (r *Replica) applySnapshotRaftMuLocked(
577
599
subsumedDescs : subsumedDescs ,
578
600
}
579
601
602
+ _ = applySnapshotTODO
580
603
clearedUnreplicatedSpan , clearedSubsumedSpans , err := prepareSnapApply (ctx , prepInput )
581
604
if err != nil {
582
605
return err
@@ -611,12 +634,14 @@ func (r *Replica) applySnapshotRaftMuLocked(
611
634
var ingestStats pebble.IngestOperationStats
612
635
var writeBytes uint64
613
636
if applyAsIngest {
637
+ _ = applySnapshotTODO // all atomic
614
638
exciseSpan := desc .KeySpan ().AsRawSpanWithNoLocals ()
615
639
if ingestStats , err = r .store .TODOEngine ().IngestAndExciseFiles (ctx , inSnap .SSTStorageScratch .SSTs (), inSnap .sharedSSTs , inSnap .externalSSTs , exciseSpan ); err != nil {
616
640
return errors .Wrapf (err , "while ingesting %s and excising %s-%s" ,
617
641
inSnap .SSTStorageScratch .SSTs (), exciseSpan .Key , exciseSpan .EndKey )
618
642
}
619
643
} else {
644
+ _ = applySnapshotTODO // all atomic
620
645
err := r .store .TODOEngine ().ConvertFilesToBatchAndCommit (
621
646
ctx , inSnap .SSTStorageScratch .SSTs (), clearedSpans )
622
647
if err != nil {
0 commit comments