Repository navigation
Backport #5136: [world-postgres] Don't move an ended run back to running on a late run_started - #5138
Merged
Merged
Conversation
…n_started (#5136) A `run_started` that arrives just as the run ends used to set the run back to running. The row was left with its output and completion time still set, and reading the run then failed. Now the late `run_started` leaves the ended run alone and is refused, the same answer it would have gotten had the run already ended when it was checked. - The UPDATE that marks the run running now skips runs in a terminal status. If it matches nothing because the run has ended, the event fails with `RunExpiredError` and no `run_started` is written. This showed up as `ZodError` failures from `runs.get` in the world-postgres e2e lanes, in the `start({ hook })` "start or resume" test: https://github.com/vercel/workflow/actions/runs/40935700151 Added a test that reproduces the race every time. A second connection ends the run and holds its row lock while `run_started` waits on that lock. Against a local Postgres 17 the test fails without the fix (the run comes back `running`) and passes with it. The world-postgres storage and spec tests pass locally. --------- Signed-off-by: Alex Langenfeld <alex.langenfeld@vercel.com>
🦋 Changeset detectedLatest commit: e8eeceb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
VaguelySerious
approved these changes
Oct 31, 2026
Contributor
Author
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🌍 Community Worlds (105 failed)redis (20 failed):
turso (85 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
|
This branch was successfully deployed
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.
Automated backport of #5136 to
stable(backport job run).AI recommendation: This fixes a correctness race in
@workflow/world-postgres: a laterun_startedcould move an ended run back torunning, which left a corrupt row that later failedruns.getwith aZodError. The same unguardedrun_startedUPDATE exists onstableinpackages/world-postgres/src/storage.ts, so the bug is present there too. The change is a narrow guard plus a regression test, with apatchchangeset (some surrounding names such asTERMINAL_WORKFLOW_RUN_STATUSESdiffer onstableand may need minor adaptation).Merge conflicts were resolved by AI (opencode with
anthropic/claude-opus-5.5). Please review the conflict resolution carefully before merging.