cockroachdb / cockroachdb/cockroach
kvserver: make `Replica.internalRaftGroup` always non-nil
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
In #104657, we eagerly initialize Raft groups on replica creation. However, during replica destruction, we nil out the Raft group to garbage collect the associated memory. This increases the replica state space (which is already complex), necessitates nil checks throughout the code base, and risks nil pointer exceptions in rare cases.
We should make it so that `Replica.internalRaftGroup` is never nil, and remove the associated checks. This probably requires more timely garbage collection of stale replicas, to release their memory (see e.g. #102000). Many tests also construct replicas without Raft groups.
Jira issue: CRDB-29873
Contributor guide
Assessment
This issue has not been assessed yet.