Title: [BUG] Race Condition: Resume request fails with "Paused execution not found" during pause persistence · Issue #3081 · simstudioai/sim · GitHub
Open Graph Title: [BUG] Race Condition: Resume request fails with "Paused execution not found" during pause persistence · Issue #3081 · simstudioai/sim
X Title: [BUG] Race Condition: Resume request fails with "Paused execution not found" during pause persistence · Issue #3081 · simstudioai/sim
Description: Problem Description There is a race condition between the persistence of a paused workflow execution and the processing of incoming resume requests. If a resume request (e.g., via API) arrives immediately after a workflow pauses but befo...
Open Graph Description: Problem Description There is a race condition between the persistence of a paused workflow execution and the processing of incoming resume requests. If a resume request (e.g., via API) arrives imme...
X Description: Problem Description There is a race condition between the persistence of a paused workflow execution and the processing of incoming resume requests. If a resume request (e.g., via API) arrives imme...
Opengraph URL: https://github.com/simstudioai/sim/issues/3081
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Race Condition: Resume request fails with \"Paused execution not found\" during pause persistence","articleBody":"## Problem Description\nThere is a race condition between the persistence of a paused workflow execution and the processing of incoming resume requests. If a resume request (e.g., via API) arrives immediately after a workflow pauses but before the `pausedExecutions` record is fully committed to the database, the resume attempt fails with a \"Paused execution not found\" error.\n\nThis is critical for high-throughput automation where external systems may attempt to resume a workflow milliseconds after it enters a paused state.\n\n## Current Behavior\n1. **Workflow Execution:** A workflow reaches a pause point.\n2. **Persistence Start:** The system calls `PauseResumeManager.persistPauseResult` to save the state.\n3. **Race Window:** During the DB write operation, an external API calls the resume endpoint (`/api/resume/...`).\n4. **Resume Check:** The resume API calls [enqueueOrStartResume](cci:1://file:///home/h30s/Project/sim/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts:162:2-279:3), which attempts to fetch the `pausedExecutions` record.\n5. **Failure:** Since the record is not yet visible/committed, the fetch returns null, and the API throws `Paused execution not found`.\n6. **Persistence End:** [persistPauseResult](cci:1://file:///home/h30s/Project/sim/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts:103:2-160:3) completes, but the valid resume request has already been rejected.\n\n## Affected Files\n- [apps/sim/background/workflow-execution.ts](cci:7://file:///home/h30s/Project/sim/apps/sim/background/workflow-execution.ts:0:0-0:0)\n- [apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts](cci:7://file:///home/h30s/Project/sim/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts:0:0-0:0)\n- [apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.ts](cci:7://file:///home/h30s/Project/sim/apps/sim/app/api/resume/%5BworkflowId%5D/%5BexecutionId%5D/%5BcontextId%5D/route.ts:0:0-0:0)\n\n## Recommended Fix\nWrap the pause persistence and the subsequent queue processing in a database transaction. This ensures that the paused state is atomically visible to any concurrent resume requests, or properly locks the row so the resume request waits until the transaction completes.\n\n**Proposed Implementation:**\nModify [persistPauseResult](cci:1://file:///home/h30s/Project/sim/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts:103:2-160:3) to use a transaction that includes both the insertion of the paused execution and the checking of the resume queue.","author":{"url":"https://github.com/h30s","@type":"Person","name":"h30s"},"datePublished":"2026-01-30T19:00:04Z","url":"https://github.com/simstudioai/sim/issues/3081"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f365bbb7-312d-d314-8a80-8abaa6d95604 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B862:9464C:152DFF8:1CE201E:6AFB77A3 |
| html-safe-nonce | f2b2e2e228395ecbb72a674361d330930f99dc39c02feffb4bbcbb49d0076251 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODYyOjk0NjRDOjE1MkRGRjg6MUNFMjAxRTo2QUZCNzdBMyIsInZpc2l0b3JfaWQiOiI0MzkwMTYxNDE2Nzk5ODc3MDI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0d54395290fa1788d93d4b3285bc1909d2654486853b687094f6ccbd6aa3dca7 |
| hovercard-subject-tag | issue:3876976483 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/simstudioai/sim/3081/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a7947c99b46440d76d501a1cabb4263d78eee50d8a931ea56d35260b1c9ab696/simstudioai/sim/issues/3081 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a7947c99b46440d76d501a1cabb4263d78eee50d8a931ea56d35260b1c9ab696/simstudioai/sim/issues/3081 |
| og:image:alt | Problem Description There is a race condition between the persistence of a paused workflow execution and the processing of incoming resume requests. If a resume request (e.g., via API) arrives imme... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | h30s |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0e29e7974fdda2feeaf5c891efd4b23b0734b23480232b62c7bdef13f40b5b48 |
| turbo-cache-control | no-preview |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2e8872b770cc4d5d0cc1f2026afab747a268e2ce |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width