Repository navigation
fix(api): an exec session's closing is decided under a lock on the session (closes #489) - #562
Conversation
…ssion A check, a retry of the end and another process's check each took the closing decision in two steps: read the closings, then publish one. Two of them could both find none and record two closings. The decision now takes a PostgreSQL transaction-level advisory lock on the session first, and a check finds a session whose end this process is still writing and looks at it again later. Closes #489. Signed-off-by: samuel mbabhazi <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 47 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
|
@coderabbitai About the inconclusive Linked Issues check: #489 has two parts. The original issue (criteria a to f) was closed by #511 on 2026-11-26. Its retry and restart tests are still at this PR's head (b8cddc0):
The reopening on 2026-11-27 asked for one thing: an atomic closing decision per session, so that overlapping checks, retries and processes cannot each publish a closing. Its acceptance is PostgreSQL races of recovery against recovery, and of an ending against recovery, each with exactly one closing outcome. Lost-response retries stay idempotent, restart recovery still works, and cleanup stays prompt. This PR delivers that:
So closing #489 here is intended: nothing from either part is left open. |
Signed-off-by: samuel mbabhazi <[email protected]>
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
At I no longer recommend narrowing the GitHub reported the TypeScript and PostgreSQL/Docker integration checks as passing. It also reported the PR merge state as Learnings added
Learnings used
You are interacting with an AI system. |
|
@coderabbitai review |
Action not completed
|
Signed-off-by: samuel mbabhazi <[email protected]> # Conflicts: # docs/SPEC.md
What
This PR fixes the follow-up reopened on #489: an exec session's closing is now decided atomically, once per session.
Before, three paths each read the session's closings, then published one, in two separate steps: the check (the startup sweep and the queue's worker), the retry of the session's end, and another API process's check. Two of them could both find no closing and both publish one.
ExecSessionClosingLock, a new port infleet/application/ports.ts. Its PostgreSQL adapter isPrismaExecSessionClosingLock, which takespg_advisory_xact_lockon a key hashed from the session's id. This follows the placement and registry locks.ExecSessionRegistry.closeOnce(session, closing)takes the lock, reads the closings, and publishes only when none is recorded. The end, each of its retries, and the checks all go through it. The end's first attempt now also reads before it writes, so a closing recorded by another process's check is never contradicted.ending(id)): it reschedules it as it does a live one, so its own process's end is not raced at all.Why
The issue asks for exactly one closing per session, as an end or as an interruption, even when checks, retries and processes overlap. The lock is the "equivalent serialization" the issue allows. It needs no schema change and no new constraint on the audit table.
How it was tested
exec-relay.spec.ts) check that the lock is taken before the closings are read, that nothing is published when a closing exists, and that the end goes through the lock and reportsendinguntil it is written. The relay tests that waited one microtask now wait onsettle, because publishing comes after the lock and the read.exec-session-checks.integration.spec.ts):exec.session.interrupted;live, and onlyexec.session.endedis recorded.api:lintandapi:typecheckpass.Security considerations
Closes #489.
Summary by CodeRabbit