cockroachdb/cockroach
Store-liveness leases
Store-liveness is CockroachDB's newer fabric for replica leadership and range leases. It replaces a single, hot "liveness range" with a per-store gossiped fence, decoupling lease and leadership decisions from a global hot spot.
What changes
- Old (epoch leases) — every node holds an epoch in the liveness range; if a peer's epoch advances, all leases held by the previous epoch are forfeited. This requires every node to repeatedly read and write the liveness range.
- New (store-liveness) — every store advertises a "support" vector to its peers. A store can claim leadership only as long as a quorum of peers continues to support its current epoch. Heartbeats are local store-to-store, not global.
Code
pkg/kv/kvserver/storeliveness/— the fabric: vouchers, support exchange, durable per-store records.pkg/raft/raftstoreliveness/— Raft adapter that asks the fabric whether a leader's epoch is still supported.pkg/kv/kvserver/leases/— the in-tree lease types (epoch-based vs store-liveness-based).pkg/kv/kvserver/replica_store_liveness.goandreplica_store_liveness_sleep.go— replica integration.
Migration story
Both lease kinds coexist in mixed-version clusters. A cluster version gate in pkg/clusterversion/ decides when a range can transition to store-liveness leases. The replicate_queue and the lease_queue cooperate to upgrade ranges as soon as it is safe.
Related pages
- Raft — leader-election integration.
- KV server — replica/leases.
- Cluster version & upgrade — gating and migration.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.