cockroachdb / cockroachdb/cockroach

kvserver: make `Replica.internalRaftGroup` always non-nil

Open
#107,068 1 comment 0 reactions 0 assignees View on GitHub
A-kv-replication C-cleanup T-kv
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.