cockroachdb / cockroachdb/cockroach

kvserver: avoid node liveness range check under closedTimestampPolicyRLocked

Open
#143,648 1 comment 0 reactions 0 assignees View on GitHub
A-kv-server branch-master C-bug T-kv
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

This patch https://github.com/cockroachdb/cockroach/pull/143625 changes range closed timestamp policies by refreshing them up-front instead of on-demand during closedTimestampPolicyRLocked. This allows closedTimestampPolicyRLocked to return cached closed timestamp policies on replicas directly, reducing the time we are spending under the `r.mu.RLock()`.

Policies are now refreshed on demand during specific events:
- when there is a leaseholder change `leasePostApplyLocked`
- when there is a config change `r.SetSpanConfig`
- or periodically at the interval of `kv.closed_timestamp.policy_refresh_interval`.

The remaining goal is to ensure that node liveness ranges consistently use `ctpb.LAG_BY_CLUSTER_SETTING` policies. While the current approach is technically correct, performing key comparisons under `closedTimestampPolicyRLocked` to identify node liveness ranges can be costly. We aim to avoid this overhead if possible.

https://github.com/cockroachdb/cockroach/blob/b96c7eeba4d683fc000c4a90917e11f958eabdf3/pkg/kv/kvserver/replica.go#L1331-L1333

Specifically, we want to identify all scenarios where a range may become a node liveness range and trigger a policy refresh accordingly.

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.