Skip to content

Commit 1c79b45

Browse files
committed
kvstorage: document plan for DestroyReplica
Epic: none Release note: none
1 parent 0753dc3 commit 1c79b45

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/kv/kvserver/kvstorage/destroy.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ func ClearRangeData(
8686
return nil
8787
}
8888

89+
// DestroyReplicaTODO is the plan for splitting DestroyReplica into cross-engine
90+
// writes.
91+
//
92+
// 1. Log storage write (durable):
93+
// 1.1. Write WAG node with the state machine mutation (2).
94+
// 2. State machine mutation:
95+
// 2.1. Clear RangeID-local un-/replicated state.
96+
// 2.2. (optional) Clear replicated MVCC span.
97+
// 2.3. Write RangeTombstone with next ReplicaID/LogID.
98+
// 3. Log engine GC (after state machine mutation 2 is durably applied):
99+
// 3.1. Remove previous LogID.
100+
//
101+
// TODO(sep-raft-log): support the status quo in which 1+2+3 is written
102+
// atomically, and 1.1 is not written.
103+
const DestroyReplicaTODO = 0
104+
89105
// DestroyReplica destroys all or a part of the Replica's state, installing a
90106
// RangeTombstone in its place. Due to merges, splits, etc, there is a need
91107
// to control which part of the state this method actually gets to remove,
@@ -109,6 +125,7 @@ func DestroyReplica(
109125
if diskReplicaID.ReplicaID >= nextReplicaID {
110126
return errors.AssertionFailedf("replica r%d/%d must not survive its own tombstone", rangeID, diskReplicaID)
111127
}
128+
_ = DestroyReplicaTODO // 2.1 + 3.1 + 2.2
112129
if err := ClearRangeData(ctx, rangeID, reader, writer, opts); err != nil {
113130
return err
114131
}
@@ -124,6 +141,7 @@ func DestroyReplica(
124141
return errors.AssertionFailedf(
125142
"cannot rewind tombstone from %d to %d", ts.NextReplicaID, nextReplicaID)
126143
}
144+
_ = DestroyReplicaTODO // 2.3
127145
return sl.SetRangeTombstone(ctx, writer, kvserverpb.RangeTombstone{
128146
NextReplicaID: nextReplicaID, // NB: nextReplicaID > 0
129147
})

0 commit comments

Comments
 (0)