Repository navigation
fix: report a duplicate run that this manager does not execute - #1
Open
klaidliadon wants to merge 2 commits into
Open
klaidliadon wants to merge 2 commits into
klaidliadon wants to merge 2 commits into
Conversation
- await reads the run once before its first poll, so a budget shorter than awaitPollInterval still sees a run that is already terminal - a missed fast-path claim drops the waiter, which signal would never reach and which otherwise leaked on every duplicate start Claude-Session: https://claude.ai/code/session_017Jq12mN4YqPnySKYcACYmQ
- Await subscribes its own channel and removes it on return, so no exit path of the run (full semaphore, drain, claim error, abandon) can leave an entry behind - the launch-once guard moves onto the WorkflowRun handle; Start no longer registers a waiter - runLocal goes back to a plain no-op on a missed claim Claude-Session: https://claude.ai/code/session_01SZexpnMmnzp5BG2YwZyQ17
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.
Goal
A caller that starts a run with an idempotency key it already used gets the run's real outcome from
Await, even when its await budget is shorter than one poll interval. The manager also stops collecting waiters for runs it never executes.Problem it solves
Startwith a duplicate key hands back the existing run.Awaitthen waits for an in-process signal that never comes, because this manager is not executing the run, and only checks the database on a one-second ticker. With a budget under a second, the deadline fires first andAwaitreturnsStatusRunningfor a run that is alreadySucceededorStuck. A caller that mapsStuckto an error ends up reporting a parked run as in progress.StartandStartTxregister a waiter per run, and only the manager that finishes the run removes it. Every run this manager does not finish leaves its entry in the map for the life of the process: a duplicate start of a terminal run, a launch skipped because the local semaphore is full or a drain started, a failed fast-path claim, an abandoned run, or aStartTxthat is never awaited.What changes
Awaitchecks the run once before it starts polling. A terminal run returns at once, whatever the budget. A run that is still going keeps the existing signal-or-poll behavior.Awaitcall owns its waiter. It registers a channel on entry and removes it on return, so the map holds only callers that are waiting right now.signalsends to every channel registered for the run. It runs after the terminal status is persisted, so anAwaitthat registers too late to receive it reads the status from the database instead.WorkflowRunhandle.Startlaunches through its handle, and aStartTxhandle launches on its firstAwait, as before.Startno longer registers anything.