Repository navigation
fix(session-admission): reconcile a workflow Temporal has no record of - #224
Merged
Merged
Conversation
Temporal answers NOT_FOUND when it has no such execution — the launch never reached the server, or retention expired. The reconciler read that as "unknown", skipped the admission, and wrote the same error to last_error every minute, so the reservation was never cleaned up and its slot never came back. Production evidence: twelve reservations in one project held slots for four days with "RPCError: workflow not found for ID"; a cap of twenty was running four sessions. No Pod existed for any of them. NOT_FOUND is the one negative answer that is not a transport failure, so it now reconciles as closed. Every other RPC error still propagates — cleaning up behind a workflow we merely cannot reach would race its own cleanup (AD-5). Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
2 tasks
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.
What was wrong
Production project 27 had a cap of 20 and was running 4 sessions. Nine were queued, the oldest for 38 minutes. Sixteen reservations were occupied with no Pod behind them:
Twelve of them carried the same
last_error, rewritten once a minute:SessionAdmissionReconciler.rundescribes the container workflow to decide whether a reservation is still live. Any exception was swallowed intolast_error, so Temporal'sNOT_FOUND— a definitive answer that no such execution exists — was treated exactly like an unreachable server: the admission was skipped, cleanup never ran,release!was never called.adm=19had been holding a slot since 2026-09-05.The fix
execution_open?distinguishes the one negative answer that is not a transport failure:NOT_FOUND— the server looked and has no such execution (launch never reached Temporal, or retention expired). Nothing can ever report a result for it, so it reconciles as closed and proceeds to cleanup + release.RPCError— still propagates, still recorded, reservation retained. Cleaning up behind a workflow we merely cannot reach would race its own cleanup (AD-5).Tests
Two new tests in
session_admission_recovery_test.rb, both mirroring the production shape (cancelled session,acknowledgedlaunch state, anuncertainexecoperation, runtime provably absent):an execution that does not exist can never report a result)UNAVAILABLEleaves it held, error recorded)make check_allgreen: rails-test, rubocop, brakeman, system-test, eslint, typescript, fsd, fe-test, vite-build.Note on production
Prod is still on pre-#216 code, where
release!refuses on any unresolved operation rather than only a materializing one — which is why anuncertainexecpins a slot there. Both this fix and #216 need to reach prod for those 16 slots to come back; with them deployed the next reconciler pass releases all 16 on its own, no manual DB surgery.🤖 Generated with Claude Code