-
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
roachpb: cleanup speculative leases returned by NotLeaseHolderErrors #86247
roachpb: cleanup speculative leases returned by NotLeaseHolderErrors #86247
Conversation
Initially, I was leaning towards using the |
0bdccaa
to
f70d86f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back on forth on this question too. You could make an argument that the LeaseHolder
field provides stronger typing. However, the fact that lease.Speculative()
exists is compelling. It means that "speculative leases" are a more general concept, and aren't just constrained to this error path. Nice cleanup.
Reviewed 11 of 11 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)
pkg/kv/kvserver/replica_range_lease.go
line 1004 at r1 (raw file):
// current lease is not known, but the error is being created by guessing who // the leaseholder may be. func newNotLeaseHolderErrorWithSpeculativeLease(
Two nits:
- we should have this create the speculative lease, but then call
newNotLeaseHolderError
, instead of duplicating logic. - this should live below
newNotLeaseHolderError
, because that's the more commonly used function and this is a special-case variant.
pkg/kv/kvserver/replica_range_lease.go
line 1026 at r1 (raw file):
err.Lease = new(roachpb.Lease) *err.Lease = l err.LeaseHolder = &err.Lease.Replica
Should we continue to return this (with the new name) until next release? Do v22.1 clients still care about it.
Speculative leases are returned as part of NLHEs if the committed lease is not known, but there is a guess as to who the leaseholder may be. Previoulsy, there were two ways to return these -- either by populating just the LeaseHolder field on the NLHE or by populating the Lease field with an unset sequence number. This patch unifies this behavior, and going forward, we expect the latter to be the canonical form to represent speculative leases. To that effect, the LeaseHolder field in the NLHE proto is prefixed as "deprecated". We should be able to remove the thing entirely in v23.1. Release note: None Release justification: low risk change.
Fix a comment that I broke in a previous patch; remove a TODO that's since been addressed. Release justification: non production code change. Release note: None
f70d86f
to
43e787b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and it makes sense for these things to be a general concept given how they're stored/used by the RangeCache.
TFTR!
bors r=nvanbenschoten
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)
pkg/kv/kvserver/replica_range_lease.go
line 1004 at r1 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Two nits:
- we should have this create the speculative lease, but then call
newNotLeaseHolderError
, instead of duplicating logic.- this should live below
newNotLeaseHolderError
, because that's the more commonly used function and this is a special-case variant.
Good calls, changed.
pkg/kv/kvserver/replica_range_lease.go
line 1026 at r1 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Should we continue to return this (with the new name) until next release? Do v22.1 clients still care about it.
Clients don't care about this thing if err.Lease
is set, so removing this should be fine.
Build failed (retrying...): |
Build failed (retrying...): |
Build failed (retrying...): |
Build succeeded: |
Speculative leases are returned as part of NLHEs if the committed lease
is not known, but there is a guess as to who the leaseholder may be.
Previously, there were two ways to return these -- either by populating
just the LeaseHolder field on the NLHE or by populating the Lease field
with an unset sequence number. This patch unifies this behavior, and
going forward, we expect the latter to be the canonical form to
represent speculative leases. To that effect, the LeaseHolder field in
the NLHE proto is prefixed as "deprecated". We should be able to remove
the thing entirely in v23.1.
Release note: None
Release justification: low risk change.