Repository navigation
Conversation
Per-user concurrency was a counter incremented on admission and decremented on completion; retries and races (finalizer replay, cancel vs completion, a lost DynamoDB reply, the stranded-task reconciler) could release a seat twice or never. - Each admitted task carries a concurrency_slot marker (held -> released). acquireTaskSlot / releaseTaskSlot (shared/task-concurrency.ts) change the marker and the counter in one transaction: acquire needs SUBMITTED with no marker and room under the cap; release needs a held marker on a terminal task. Lost replies are recovered from the marker; transaction conflicts retry with bounded jitter. - Admission, finalization (release in finally), failTask, the orchestrator's early-return paths and the stranded-task reconciler all release through the marker; no handler decrements active_count directly. confirm-uploads no longer reserves at submit; the orchestrator owns admission. - A held task can never be re-queued (SUBMITTED -> QUEUED and the admission queue require no marker). - An approval wait that outlives the poll window finalizes to FAILED. It used to attempt the invalid AWAITING_APPROVAL -> TIMED_OUT, leave the task active and still free its seat. A finalization that cannot reach a terminal state now throws and is retried, keeping the seat. - The concurrency reconciler reads counters, then strongly reads every reservation, repairs only under the observed reservation_version, and releases terminal reservations left by interrupted cleanup. Users with unmarked active tasks (admitted before this change) are skipped until they settle. - DynamoDB Local race suite (15 cases) runs when ABCA_DDB_LOCAL_ENDPOINT is set; ORCHESTRATOR.md documents the scheme and the upgrade/drain note. Rebased onto main after the Lambda MicroVM approval lifecycle (#904): the MicroVM supervisor-failure path no longer decrements the counter itself. finalizeTask keeps the worker-ownership check (a changed owner neither mutates the task nor releases its seat) and releases in `finally`; the MicroVM finalization tests assert the release instead of the decrement. (cherry picked from commit adb9b2c)
…in tests The replayed-finalize double release and the reconciler that dropped the seat of a task awaiting approval were test.failing witnesses until this fix. The leaked-seat test now writes the leak to the counter directly: admission ties every seat to a task record. (cherry picked from commit 2487167)
4 of 5 tasks
5 tasks done
This branch has not been deployed
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 seat release from #1009, rebased onto current main and split out of #1086 as the reviewer asked. The change is the same; the emulator tests that recorded these defects as known failures are now plain tests.
Area
cdk— infrastructure, handlers, constructsagent— Python runtime / Docker imagecli—bgagentclientdocs— guides or design sources (docs/guides/,docs/design/)tooling— rootmise.toml, scripts, CI workflowsRelated
Closes #1003. Replaces #1009 (closed when it was folded into #1086).
Each task now holds a reservation marker (
concurrency_slot: held → released, versioned). Taking and returning a seat is one DynamoDB transaction with the per-user counter, so a seat is released exactly once, under retries, finalizer replays, cancel/complete races and lost replies alike.Changes
shared/task-concurrency.ts:acquireTaskSlot/releaseTaskSlot, transactional with the counter, and conditioned on the task's own marker.orchestrator.ts:acquireTaskSlot;finalizeTaskreleases infinally;failTaskrethrows when the task isn't terminal;decrementConcurrencyis removed.orchestrate-task.ts: consistent reads, plus release steps on the early-return paths. Only new paths are added, so in-flight durable executions replay unchanged.reconcile-concurrency.ts,reconcile-stranded-tasks.tsand the admission queue: they repair drift through the marker and never release another task's seat.reconcile-stranded-tasksno longer decrements the counter directly.confirm-uploadsno longer reserves capacity at submit. The orchestrator owns admission, so an upload-confirmed task over the cap is queued like any other submission, instead of rejected with 429.ORCHESTRATOR.md: the new scheme, plus an upgrade note.Upgrade
Drain in-flight tasks before deploying. Tasks admitted before this change have no marker; they can't release another task's seat, and their user's count is treated as ambiguous until they finish.
Tests
mise run test:integrationtier, cdk): 29 passed, including the three seat tests. Two of them weretest.failingwitnesses for this defect on main (a replayed finalize releasing a second seat, and the reconciler dropping the seat of a task awaiting approval) and now pass as plain tests. The leaked-seat test writes the leak to the counter directly, because admission now ties every seat to a task record.task-concurrency-local.test.ts): 15/15 as in fix(orchestration): exactly-once concurrency seat release #1009.Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.