Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: issue replication lag probe before lease transfer #96304

Open
nvanbenschoten opened this issue Jan 31, 2023 · 2 comments
Open

kv: issue replication lag probe before lease transfer #96304

nvanbenschoten opened this issue Jan 31, 2023 · 2 comments
Labels
A-kv Anything in KV that doesn't belong in a more specific category. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-kv KV Team

Comments

@nvanbenschoten
Copy link
Member

nvanbenschoten commented Jan 31, 2023

Problem

In #81561, we outlined the risk of range unavailability due to lease transfers sent to lagging followers. Recall that a follower replica must apply a lease transfer through its Raft log before it can take over as a leaseholder. This means catching up on its log first, if it is behind. During the period where the incoming leaseholder is catching up on its log, the range is unavailable.

In that issue, we focused on followers that needed a Raft snapshot to catch up on their log. These situations result in high and unpredictable replication lag. Snapshots require a bulk transfer of data which is queued and paced.

However, there is a less severe form of the same issue. Lease transfers may still cause unavailability if the incoming leaseholder is connected to the leader's log (i.e. does not need a snapshot), but is trailing by many log entries. In general, any meaningful replication lag is a problem for lease transfers.

Proposed solution

To place a soft bound on the period of unavailability, we could first measure the replication lag of the prospective leaseholder before transferring it the lease. If the lag is too much, we could reject the lease transfer. One way to accomplish this would be to measure the duration of a fake write to be applied on the prospective leaseholder when pushed through Raft. We have most of the infrastructure needed to support this. See WaitForApplication.

Note that we cannot mandate that the follower is all the way caught up on its log. This could prevent followers that have a small but persistent lag due to network latency and steady traffic from ever qualifying for the lease, which is what we saw in #38065.

Jira issue: CRDB-24054
Epic CRDB-39898

@nvanbenschoten nvanbenschoten added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-kv-distribution Relating to rebalancing and leasing. A-kv Anything in KV that doesn't belong in a more specific category. T-kv KV Team labels Jan 31, 2023
@tbg tbg added T-kv-replication and removed A-kv-distribution Relating to rebalancing and leasing. T-kv KV Team labels Mar 30, 2023
@blathers-crl
Copy link

blathers-crl bot commented Mar 30, 2023

cc @cockroachdb/replication

@exalate-issue-sync exalate-issue-sync bot added A-kv-distribution Relating to rebalancing and leasing. T-kv KV Team and removed T-kv-replication labels Mar 30, 2023
@exalate-issue-sync exalate-issue-sync bot added T-kv-replication and removed A-kv-distribution Relating to rebalancing and leasing. T-kv KV Team labels Apr 5, 2023
@blathers-crl
Copy link

blathers-crl bot commented Apr 5, 2023

cc @cockroachdb/replication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-kv Anything in KV that doesn't belong in a more specific category. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-kv KV Team
Projects
None yet
Development

No branches or pull requests

3 participants