pin the reservation to the lease try_reserve actually charged - #123
Merged
bpapillon merged 1 commit intoSep 17, 2026
Conversation
schematic-bot
approved these changes
Sep 17, 2026
bpapillon
deleted the
bpapillon/sch-7487-sdk-reservation-can-pin-the-wrong-lease-id-when-the-slots
branch
September 17, 2026 00:51
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.
The client-mode check took the lease ID from
acquire_if_neededand then calledtry_reserve, which debits whichever lease the slot holds at that moment and is not keyed by lease ID. Between the two calls the slot's lease can be replaced: the window spans the awaited extend, and the sweeper or a sibling pod can install a successor. The credits then came out of the new lease while the reservation pinned the old one, so the settle and sweep refunds were dropped and the track event billed a released lease.Ports the shape from schematic-node #186.
try_reservenow returns the post-debit balance and the lease it charged as aReserveResult, read under the same lock as the debit in memory and inside the same script on Redis. The Lua body is byte-identical to Node's, and the key layout and hash fields are unchanged, so mixed fleets keep sharing one Redis. The reservation record, the failed-persist undo, and through the record the track event all pin the returned ID.SPEC.md and the lease-lifecycle vectors carry Node's additions verbatim. Tests cover the swap window on both backends, the settling track event carrying the successor's ID, and the real extend window on a shared fakeredis.
Shares a test helper with #122; whichever merges second needs a small rebase.