Repository navigation
fix(gateway): treat a lock stamped beyond the drift bound as expired - #1600
Merged
Merged
Conversation
kvinwang
force-pushed
the
fix/gateway-lock-future-stamp
branch
from
November 18, 2026 08:06
30c588d to
ee657dd
Compare
release_lock could delete a successor's lease. A delete is stamped with local wall time and wins LWW over any lock stamped earlier: - The value (started_at seconds, started_by) is not unique: after a force release the same node can re-acquire in the same second, and the stale holder's release matched and deleted the successor's lock. Add a random nonce to the value. - An absent key (already released or force-released) also fell through to the delete, which could beat a successor's lock not yet received. Delete only when the current value is ours. - A holder past its timeout could delete a lease a peer had already taken over unseen. A peer takes over only once its clock reads started_at + timeout, stamping its lock no earlier, so a delete before the holder's clock reaches that point cannot beat it whatever the skew. Past it, leave the lease to expire; release now takes the timeout, like acquire. The nonce is a serde-default field of a map-encoded value, so older gateways ignore it and older records decode with nonce 0; the legacy fixture now encodes the real two-field shape. Signed-off-by: Kevin Wang <wy721@qq.com>
A renew or rotation lease whose started_at lies in the future (a holder clock since stepped back, or a corrupt value near u64::MAX) held the key until wall time caught up. The per-domain lock has an admin force release, but the shared ACME lock does not, and holding it blocks rotation, CAA reconciliation and first-use account registration. Treat a lease stamped more than MAX_CLOCK_DRIFT_SECS ahead of local time as expired, the same horizon already applied to replicated observations; a peer clock ahead within the bound is still honoured. Also correct comments and a test name that described acquire_acme_lock as waiting: it fails immediately when the lock is held. Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
fix/gateway-lock-future-stamp
branch
from
November 18, 2026 08:28
ee657dd to
aa82462
Compare
kvinwang
enabled auto-merge
November 18, 2026 08:28
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.
A renew/rotation lease with
started_atin the future (a holder clock since stepped back, or a corrupt value) held the key until wall time caught up. For the shared ACME lock there is no force release, so that blocked rotation, CAA reconciliation and first-use registration.try_acquire_locknow treats a lease stamped more thanMAX_CLOCK_DRIFT_SECS(300 s) ahead as expired, the horizon already used for replicated observations; a peer clock ahead within the bound is still honoured.lease_expiry_does_not_overflowasserted the old behaviour and is replaced.Also fixes comments and a test name that said
acquire_acme_lockwaits; it fails immediately.Merge after #1598 (wavekv 2.2): the takeover write must be stamped above the future-stamped entry it replaces, or peers that admitted that entry keep it. Touches the same function as #1599; rebase after it lands (
noncein the test literal).