Skip to content

Commit e4b2d35

Browse files
craig[bot]pav-kv
andcommitted
Merge #150189
150189: kvstorage: fix CreateUninitializedReplica comment r=arulajmani a=pav-kv The scenario described in the comment was possible before it became an invariant that all replicas have a `RaftReplicaID` in storage. Since we completed a migration [#95513] which established this invariant, we can remove this comment. Historical context: https://github.com/cockroachdb/cockroach/pull/75761/files#diff-208036c53fab5274d107185f7b974421738b6cd54b849000a60656c764ba2b08R224-R272 Epic: none Release note: none Co-authored-by: Pavel Kalinnikov <[email protected]>
2 parents 7df163f + f66721f commit e4b2d35

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pkg/kv/kvserver/kvstorage/replica_state.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,10 @@ func CreateUninitializedReplica(
135135

136136
// Write the RaftReplicaID for this replica. This is the only place in the
137137
// CockroachDB code that we are creating a new *uninitialized* replica.
138-
// Note that it is possible that we have already created the HardState for
139-
// an uninitialized replica, then crashed, and on recovery are receiving a
140-
// raft message for the same or later replica.
141-
// - Same replica: we are overwriting the RaftReplicaID with the same
142-
// value, which is harmless.
143-
// - Later replica: there may be an existing HardState for the older
144-
// uninitialized replica with Commit=0 and non-zero Term and Vote. Using
145-
// the Term and Vote values for that older replica in the context of
146-
// this newer replica is harmless since it just limits the votes for
147-
// this replica.
138+
//
139+
// Before this point, raft and state machine state of this replica are
140+
// non-existent. The only RangeID-specific key that can be present is the
141+
// RangeTombstone inspected above.
148142
_ = CreateUninitReplicaTODO
149143
if err := sl.SetRaftReplicaID(ctx, eng, replicaID); err != nil {
150144
return err

0 commit comments

Comments
 (0)