Skip to content

Commit f66721f

Browse files
committed
kvstorage: fix CreateUninitializedReplica comment
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 which established this invariant, we can remove this comment. Epic: none Release note: none
1 parent 1dfa255 commit f66721f

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)