Repository navigation
dagql: make session ownership claims atomic - #13934
Merged
Merged
Conversation
Record session ownership and its counter unit in one critical section, retain engine-lifetime release tombstones, and reject claims from released sessions. Remove failed-read edge rollbacks, apply the same lifecycle to arbitrary values, and make server session IDs single-use after teardown. Update the cache lifecycle model and add deterministic ownership, rollback, refusal, and server lifecycle coverage. Signed-off-by: Erik Sipsma <[email protected]>
sipsma
marked this pull request as ready for review
August 20, 2026 02:31
Signed-off-by: Erik Sipsma <[email protected]>
This was referenced Aug 20, 2026
nextSharedResultID no longer resets to zero when the e-graph empties, so a numeric result ID can never name two different results within one engine process. Import's counter write is forward-only for the same reason. With that invariant, every registry identity check becomes a plain membership check by ID instead of a pointer comparison. The arbitrary-value cache gets its own engine-lifetime-unique entry ID, allocated under callsMu, replacing the pointer comparisons on its call-key-keyed maps while still protecting a successor entry under a reused call key from deletion by a stale holder. Also corrects the spec header's stale description of the arbitrary-value cache claim shape. Signed-off-by: Erik Sipsma <[email protected]>
This was referenced Aug 24, 2026
vito
approved these changes
Aug 26, 2026
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.
Summary
Make dagql session ownership claims atomic, remember released sessions for the engine lifetime, and reject claims that arrive after release. Apply the same lifecycle to the arbitrary-value cache, remove three unsafe failed-read rollbacks, and make server session IDs single-use after successful teardown.
This branch lives in
dagger/daggerbecause it is the bottom layer of a planned same-repository pull request stack. This pull request targetsmain; later dependent layers can target this branch.Problem
The cache represents a session's ownership of a result in two places: a record in
sessionResultIDsBySessionand one unit in the result's incoming ownership counter. Those were written in separate locked steps, and the cache did not know whether a session had already been released.That left several harmful interleavings:
The arbitrary-value cache had the same split record-and-counter structure.
Changes
egraphMuthensessionMucritical section. Convert request lookup, digest lookup, result-ID lookup, waiter publication,AttachResult, attachedDoNotCacheresults, and list-element access to it.callsMuthensessionMufor arbitrary cached values.Behavior changes
Model
Update the TLA+ cache lifecycle specification to model result claims as one atomic action while keeping session release as its two real critical sections. Refusal is a distinct terminal outcome, and final refused waiters still use the normal handoff-release action so late persistence intent is repaired before temporary ownership is dropped.
Five former expected violations are now green regression gates: post-release orphan claims, release consuming another ownership unit, nested post-drain orphan claims, failed-read rollback after cancellation, and failed persisted-decode rollback. The separate returned-after-release problem remains out of scope: the
release_inflightanddrain_escapeconfigurations still violateReturnedLiveexactly as expected.Validation
go test ./dagql -count=1go test ./engine/server -count=1go test -race ./dagql -run 'TestCache(SessionResultClaimAndReleaseAreAtomic|RefusedFinalWaiterRepairsPersistenceBeforeHandoffRelease|ArbitrarySessionClaimAndReleaseAreAtomic|ArbitraryRefusedOwnerReleasesUnownedValue|ReleasedSessionErrorIncludesSessionID)$' -count=1go test -race ./dagql -run '^TestCacheArbitrary' -count=1go test -race ./engine/server -run 'Test(SameIDConnectDuringBackgroundTeardownGetsRetryable|ReapAbandonedWhenMainClientReconnects|FailedSessionInitializationCanRetrySameID|RetireSessionIsPointerConditional|MainClientLastDisconnectDoesNotBlockOnTeardown)$' -count=1dagger check tla-check:cache-lifecycle