Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 97dd188 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
|
@himself65 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
…orld Every process running the Postgres World against one database claims from the same Graphile Worker queue, and a process that should stop taking work while it stays up, such as a blue-green revision that no longer receives traffic but is still draining, had no way to: close() is final, and a runner stopped any other way comes back on the next enqueue, because queue() calls start(). Add pauseClaims() and resumeClaims() to the queue and the world. Pausing stops the runner gracefully, so jobs already running finish; while paused, neither start() nor queue() starts another, and enqueueing, streams and storage keep working. Resuming starts only the runner, without repeating the active-run recovery world.start() performs. close() waits for a runner a pause is still stopping. Pause and resume apply in call order. Closes vercel#4500 Signed-off-by: Alex Yang <himself65@outlook.com>
himself65
force-pushed
the
world-postgres-pause-claims
branch
from
October 8, 2026 01:55
4cf566c to
97dd188
Compare
2 of 3 tasks
2 of 3 tasks
|
upvote on this |
This branch has not been 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.
Description
Closes #4500.
Every process running the Postgres World against one database claims from the same Graphile Worker queue. A process that should stop taking new work while it stays up had no way to do so. The typical case is a blue-green revision that no longer receives traffic but is still draining its streams and steps:
world.close()is final: it closes the streamer and releases the worker utils.queue()callsstart().This adds
pauseClaims()andresumeClaims()to the queue, and through it to the world:pauseClaims(). Graphile Worker's runner stops gracefully, so jobs already running finish and are recorded as usual. While paused, neitherstart()norqueue()starts another runner. Enqueueing, streams and storage keep working. It resolves once the stop has begun, not once the stopped runner's jobs are done.resumeClaims(). It starts only the runner. It does not repeat thereenqueueActiveRuns()recovery thatworld.start()performs, which would re-enqueue every active run again. Beforestart()has run, it only lifts the pause.close()also waits for a runner that a pause is still stopping, so a job finishing after the pause can still enqueue its reschedule before the worker utils are released.The world-postgres README and the v5 Postgres World docs get a short "Pausing claims" section.
How did you test your changes?
src/queue.test.ts(mocked Graphile Worker, same setup as the existing queue tests):resumeClaims()starts a runner without repeatingstart();start()only lifts the pause;close()waits for it before releasing the worker utils;close()starts nothing.src/reenqueue.test.ts. A pausedworld.start()re-enqueues active runs once, andworld.resumeClaims()starts the runner without re-enqueueing them again.test/queue-claims.test.ts(real Graphile Worker and Postgres via testcontainers, with a loopback executor):close()waits for it; a job enqueued after the pause stays unclaimed.startRunnerWhenExecutorIsReady()fails the unit and integration cases. So does removing the wait for stopping runners inclose().mainat d0f6b91.pnpm --filter @workflow/world-postgres test, with Docker available and the package built: 20 files, 331 tests. The tests this PR adds or changes passed in all four local runs. Two existing integration tests flaked locally on macOS:storage.test.ts› "should release a retained hook after its deadline" failed in 2 of 4 runs here and 1 of 3 runs onmain. It compares a host-clock deadline with Postgresnow().57P01(terminating connection due to administrator command) was reported in 2 of 4 runs here and in none of 3 onmain. Vitest attributed it tostream-offset.test.tsandlisten-reconnect.test.ts, which do not use the queue. It did not reproduce in isolation:queue-claims.test.tsalone passed 5 of 5 runs, and those two files together passed 8 of 8, all without it.tsc --noEmitandbiome checkare clean for the touched files. The only warnings are the same onesmainreports, in functions this PR does not change.The same change, as a patch on
@workflow/world-postgres@4.3.6, is how our service stops a drained blue-green revision from claiming. A local two-process simulation of a cut is summarized in #4500.PR Checklist - Required to merge
pnpm changesetwas run to create a changelog for this PR (minor)git commit --signoffon your commits)@vercel/workflowin a comment once the PR is ready, and the above checklist is complete