Skip to content

fix(world-postgres): make step creation atomic - #3575

Open
shin4141 wants to merge 1 commit into
vercel:mainfrom
shin4141:codex/v42-atomic-step-created-event
Open

fix(world-postgres): make step creation atomic#3575
shin4141 wants to merge 1 commit into
vercel:mainfrom
shin4141:codex/v42-atomic-step-created-event

Conversation

@shin4141

Copy link
Copy Markdown

What

  • insert a Postgres step entity and its matching step_created event in one transaction
  • keep event-slot allocation and entity-conflict handling inside the existing read-committed semantics
  • add a deterministic regression that forces the event insert to fail and verifies the step claim rolls back
  • add the required patch changeset for @workflow/world-postgres

Why

step_created previously committed the workflow_steps row before attempting the workflow_events insert. If the process or database failed between those writes, replay had no creation event while the exactly-once entity claim remained. Subsequent replay could only rediscover the same conflict and leave the run wedged.

This fixes the step_created partial-write window reported in #3081 without changing the public event contract or expanding the repair to other event types.

Root cause and impact

The entity mutation and its replay evidence used separate autocommit statements. The repair moves only this pair behind a single transaction. A failed event write now rolls the entity claim back; a successful call still returns the same step/event result and preserves dense event slots.

Checks

  • red-before: forced event-insert failure left { stepId: 'step_partial_write' } in workflow_steps
  • green-after: targeted rollback regression passed
  • packages/world-postgres/test/storage.test.ts: 141 passed against an isolated PostgreSQL 17.10 database with repository migrations
  • @workflow/world-postgres build: passed
  • @workflow/world-postgres typecheck: passed
  • queue tests: 12 passed
  • re-enqueue tests: 12 passed
  • util tests: 2 passed
  • Biome check: no errors (repository-existing warnings remain)
  • changeset status: @workflow/world-postgres patch detected

The repository-standard Testcontainers spec suite is left to CI because Docker is not available in the local execution environment.

@shin4141
shin4141 requested a review from a team as a code owner August 15, 2026 03:43
@changeset-bot

changeset-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 82be579

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@workflow/world-postgres Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

@shin4141 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Signed-off-by: Shin <128954611+shin4141@users.noreply.github.com>
@shin4141
shin4141 force-pushed the codex/v42-atomic-step-created-event branch from b9727fe to 82be579 Compare August 15, 2026 03:44
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