-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
kvserver: failure while transferring lease away when exiting joint config can lead to range unavailability #83687
Comments
Before evaluating a TransferLeaseRequest, we revoke the existing lease. This is needed so that further reads are not permitted before the new lease takes effect without being captured in the timestamp cache summary carried by the transfer. This patch makes it so that we restore the original lease if the evaluation of the transfer fails(*), as there doesn't seem to be any reason to force the replica to acquire a new lease in that case. This patch is strictly about evaluation failing, and not about failures or ambiguity during application of the lease transfer Raft command. (*) It's not common for the evaluation of a transfer to fail. We see something going wrong with a transfer (either with the evaluation or with the proposal) in cockroachdb#83687. Evaluation fails on inconsistent next leases, which I think can happen under transfer races. Release note: None
…oming voter Fixes cockroachdb#83687. It is possible that we've entered a joint config where the leaseholder is being replaced with an incoming voter. We try to transfer the lease away, but this fails. In this case, we need the demoted voter to re-aquire the lease, as it might be an epoch based lease, that doesn't expire. Otherwise we might be stuck without anyone else getting the lease (the original leaseholder will be in the PROSCRIBED state, repeatedly trying to re-aquire the lease, but will fail since its a VOTER_DEMOTING_LEARNER). Release note (bug fix): Fixes a critical bug (cockroachdb#83687) introduced in 22.1.0 where failure to transfer a lease in the joint config may result in range unavailability. The fix allows the original leaseholder to re-aquire the lease so that lease transfer can be retried.
I think this issue may be exacerbated by 034611b. That commit adds a new case where lease transfers can fail after the outgoing lease has been revoked (placed in a PROSCRIBED state). We see in #83261 that we now hit this case more often. I suspect that this is why the lease ends up in a PROSCRIBED state in this issue. That doesn't mean that we shouldn't urgently fix this issue, but it may be more rare on v22.1 (which does not have 034611b) than we originally thought. |
83686: kvserver: allow voter demoting to get a lease, in case there's an incoming voter r=shralex a=shralex Fixes #83687. It is possible that we've entered a joint config where the leaseholder is being replaced with an incoming voter. We try to transfer the lease away, but this fails. In this case, we need the demoted voter to re-aquire the lease, as it might be an epoch based lease, that doesn't expire. Otherwise we might be stuck without anyone else getting the lease (the original leaseholder will be in the PROSCRIBED state, repeatedly trying to re-aquire the lease, but will fail since its a VOTER_DEMOTING_LEARNER). Release note (bug fix): Fixes a critical bug (#83687) introduced in 22.1.0 where failure to transfer a lease in the joint config may result in range unavailability. The fix allows the original leaseholder to re-aquire the lease so that lease transfer can be retried. Co-authored-by: shralex <[email protected]>
Anecdotally, I started seeing this only after a rebase and once I saw it the first time I kept on hitting it quite frequently. |
…oming voter Fixes cockroachdb#83687. It is possible that we've entered a joint config where the leaseholder is being replaced with an incoming voter. We try to transfer the lease away, but this fails. In this case, we need the demoted voter to re-aquire the lease, as it might be an epoch based lease, that doesn't expire. Otherwise we might be stuck without anyone else getting the lease (the original leaseholder will be in the PROSCRIBED state, repeatedly trying to re-aquire the lease, but will fail since its a VOTER_DEMOTING_LEARNER). Release note (bug fix): Fixes a critical bug (cockroachdb#83687) introduced in 22.1.0 where failure to transfer a lease in the joint config may result in range unavailability. The fix allows the original leaseholder to re-aquire the lease so that lease transfer can be retried.
This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in cockroachdb#83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. This PR also removes the leaseHolderRemovalAllowed parameter of CheckCanReceiveLease, since it is always true since 22.2. Release note (bug fix): stability fix.
This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in cockroachdb#83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. This PR also removes the leaseHolderRemovalAllowed parameter of CheckCanReceiveLease, since it is always true since 22.2. Release note (bug fix): narrows down the conditions under which a VOTER_DEMOTING_LEARNER can acquire the lease in a joint configuration to a) there has to be an VOTER_INCOMING in the configuration and b) the VOTER_DEMOTING_LEARNER was the last leaseholder. This prevents it from acquiring the lease unless it is the only one that can acquire it, because transferring the lease away is necessary before exiting the joint config (without the fix the system can be stuck in a joint configuration in some rare situations). Fixes: cockroachdb#88667 See also cockroachdb#89340
This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in cockroachdb#83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. This PR also removes the leaseHolderRemovalAllowed parameter of CheckCanReceiveLease, since it is always true since 22.2. Release note (bug fix): narrows down the conditions under which a VOTER_DEMOTING_LEARNER can acquire the lease in a joint configuration to a) there has to be an VOTER_INCOMING in the configuration and b) the VOTER_DEMOTING_LEARNER was the last leaseholder. This prevents it from acquiring the lease unless it is the only one that can acquire it, because transferring the lease away is necessary before exiting the joint config (without the fix the system can be stuck in a joint configuration in some rare situations). Fixes: cockroachdb#88667 See also cockroachdb#89340
89564: kvserver: don't allow VOTER_DEMOTING to acquire lease after transfer r=shralex a=shralex This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in #83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. This PR also removes the leaseHolderRemovalAllowed parameter of CheckCanReceiveLease, since it is always true since 22.2. Release note (bug fix): narrows down the conditions under which a VOTER_DEMOTING_LEARNER can acquire the lease in a joint configuration to a) there has to be an VOTER_INCOMING in the configuration and b) the VOTER_DEMOTING_LEARNER was the last leaseholder. This prevents it from acquiring the lease unless it is the only one that can acquire it, because transferring the lease away is necessary before exiting the joint config (without the fix the system can be stuck in a joint configuration in some rare situations). Fixes: #88667 See also #89340 Co-authored-by: shralex <[email protected]>
This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in #83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. This PR also removes the leaseHolderRemovalAllowed parameter of CheckCanReceiveLease, since it is always true since 22.2. Release note (bug fix): narrows down the conditions under which a VOTER_DEMOTING_LEARNER can acquire the lease in a joint configuration to a) there has to be an VOTER_INCOMING in the configuration and b) the VOTER_DEMOTING_LEARNER was the last leaseholder. This prevents it from acquiring the lease unless it is the only one that can acquire it, because transferring the lease away is necessary before exiting the joint config (without the fix the system can be stuck in a joint configuration in some rare situations). Fixes: #88667 See also #89340
This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in #83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. This PR also removes the leaseHolderRemovalAllowed parameter of CheckCanReceiveLease, since it is always true since 22.2. Release note (bug fix): narrows down the conditions under which a VOTER_DEMOTING_LEARNER can acquire the lease in a joint configuration to a) there has to be an VOTER_INCOMING in the configuration and b) the VOTER_DEMOTING_LEARNER was the last leaseholder. This prevents it from acquiring the lease unless it is the only one that can acquire it, because transferring the lease away is necessary before exiting the joint config (without the fix the system can be stuck in a joint configuration in some rare situations). Fixes: #88667 See also #89340
This PR restricts the case when a VOTER_DEMOTING_LEARNER can aquire the lease in a joint configuration to only the case where it was the last leaseholder. Since it is being removed, we only want it to get the lease if no other replica can aquire it, the scenario described in cockroachdb#83687 This fix solves a potential starvation scenario where a VOTER_DEMOTING_LEARNER keeps transferring the lease to the VOTER_INCOMING, succeeding, but then re-acquiring because the VOTER_INCOMING is dead and the lease expires. In this case, we would want another replica to pick up the lease, which would allow us to exit the joint configuration. Release note (bug fix): narrows down the conditions under which a VOTER_DEMOTING_LEARNER can acquire the lease in a joint configuration to a) there has to be an VOTER_INCOMING in the configuration and b) the VOTER_DEMOTING_LEARNER was the last leaseholder. This prevents it from acquiring the lease unless it is the only one that can acquire it, because transferring the lease away is necessary before exiting the joint config (without the fix the system can be stuck in a joint configuration in some rare situations). Release justification: solves a serious bug. Fixes: cockroachdb#88667 See also cockroachdb#89340
Describe the problem
@nvanbenschoten, @andreimatei, @shralex, @knz and I were looking into a closed loop workload that had been stalled for around 10 minutes. We correlated the stall with an uptick in backoffs due to NLHE errors in the dist sender.
Digging a bit deeper in the logs for one of the nodes, it turned out all these errors pertained to a single range
r54
and all NLHE errors indicated thatn16
was the lease holder. Interestingly,n16
s replica was of typeVOTER_DEMOTING
. We also seen4
has aVOTER_INCOMING
replica, so the range in question is undergoing a lateral lease transfer using a joint config.Looking at
n16s
logs next, we find log lines of the form:We also noticed from the ranges status page that
n16
's status is marked asPROSCRIBED
. This checks out, given it appears as the leaseholder to all other nodes in the cluster yet it is repeatedly trying to acquire the lease forr54
. It is repeatedly failing to acquire the lease however, which seems to be running into this check which only allowsVOTER_FULL
andVOTER_INCOMING
replicas to acquire a lease.cockroach/pkg/roachpb/metadata_replicas.go
Lines 527 to 531 in eeb7236
The proposed solution here would be to as simple as relaxing the check about to allow a
VOTER_DEMOTING
replica to acquire the lease if it is part of a joint configuration with anotherVOTER_INCOMING
replica.Jira issue: CRDB-17207
The text was updated successfully, but these errors were encountered: