fix(lock,election): add Lock/Campaign overloads that take an explicit lease - #321
Open
suleymanbyzt wants to merge 1 commit into
Open
fix(lock,election): add Lock/Campaign overloads that take an explicit lease#321suleymanbyzt wants to merge 1 commit into
suleymanbyzt wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Campaign(name, value)andLock(name)never set the lease field on the request.etcd reads an unset lease as "make one for me":
v3election/v3lockcallconcurrency.NewSession(defaultSessionTTL = 60) and then immediatelyOrphan(),which stops the keepalive. Nothing renews that lease, so the lock or the leadership
is dropped 60s after it is taken, with no signal to the caller.
measured on etcd 3.5.17, single node, no faults injected:
GrantedTTL60, TTL just counts down 59 → 51 → ... → -1, never refreshedUnlock/Resignmutex: session is expiredLeaseKeepAlive: still held after 40s with a10s TTL, contender still blocked. The server is fine, it's the missing lease.
docs/lock/api-reference.mdalready documentsLock(string, long leaseId, ...)anddocs/election/api-reference.mddocumentsCampaign(string, long leaseId, string, ...).Neither ever existed (
git log -Sis empty), so this implements the signatures youalready documented rather than inventing new ones. that's why
Campaigntakes thelease before the value.
Lease-less overloads are
[Obsolete], not removed. Docs updated to match the real API.Tests don't sleep: they read the lease off the lock key and assert
GrantedTTL, so thenew integration tests add about a second. The 60s wall-clock version is in
LeaseScopedOwnershipExpiryTestsunderCategory=Slow, which neither CI filter picksup (
dotnet test --filter "Category=Slow"to run it).Unit 356/356, Integration 63/63, no new warnings.
Left out on purpose:
Lock(string, int leaseTtl)from the docs, since it needs theclient to own a lease's lifetime and keepalive your call, not mine. Also the
ByteStringCampaign overload.