Skip to content

DRU-1095 -- A run starts only when the transaction that starts it commits - #1122

Open
czpython wants to merge 1 commit into
mainfrom
paulo/queue-a-run-after-its-transaction-commits
Open

czpython wants to merge 1 commit into
mainfrom
paulo/queue-a-run-after-its-transaction-commits

Conversation

@czpython

@czpython czpython commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Outside a workflow (a request, a webhook, a command), Workflow.start() enqueues the run in the caller's transaction through DBOS's DBOSClient.enqueue_in_transaction, so the run, its row, and its workflow.scheduled event commit together, and a rollback leaves none of them. Before, start() enqueued in DBOS's own transaction at once, so a request that failed after the start kept a run whose subject row was gone.

  • Inside a workflow, body or step, start() keeps DBOS.enqueue_workflow_async, which DBOS records as the workflow's child: a replay finds the run, and runs in flight at deploy recover as before. DBOS.workflow_id picks the path.
  • druks.durable.engine.enqueue_in_transaction runs the client call in a savepoint. A held deduplication slot raises DBOSQueueDeduplicatedError; the savepoint drops the collision, and the call returns the holder from workflow_status, or claims the slot again when the holder ended in between. The client stamps the attributes and serializes the input as an in-process enqueue does.
  • Run.create_row takes the caller's session. _execute_run and Run.retry write their rows through sessions of their own, as before.
  • The workflow_status handle reads queue_name and deduplication_id, and its grace comment no longer says the row commits before the enqueue.
  • docs/writing-an-app.md gives the rule beside the duplicate-start rule. Two tests cover a start that rolls back and a second start in the same transaction, and the failed-enqueue test now fails the in-transaction enqueue.

@mintlify

mintlify Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
druks 🟢 Ready View Preview Nov 7, 2026, 4:22 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@czpython czpython changed the title Queue a run after its transaction commits DRU-1095 -- A run starts only when the transaction that starts it commits Nov 7, 2026
@czpython
czpython force-pushed the paulo/queue-a-run-after-its-transaction-commits branch from b82aec2 to 5f340e4 Compare November 7, 2026 10:18
@czpython
czpython force-pushed the paulo/queue-a-run-after-its-transaction-commits branch from 5f340e4 to 0de10d7 Compare November 7, 2026 10:24

This branch was successfully deployed

1 active deployment
staging - docs — d7726476 Deployed Nov 7, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant