Skip to content

world-postgres: make graphile-worker pollInterval configurable - #4355

Merged
VaguelySerious merged 2 commits into
vercel:mainfrom
cwdx:world-postgres-poll-interval
Oct 1, 2026
Merged

VaguelySerious merged 2 commits into
vercel:mainfrom
cwdx:world-postgres-poll-interval

Conversation

@cwdx

@cwdx cwdx commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What

@workflow/world-postgres hardcodes graphile-worker's pollInterval: 500. This adds a pollInterval option and WORKFLOW_POSTGRES_POLL_INTERVAL_MS env var, same pattern as queueConcurrency / WORKFLOW_POSTGRES_WORKER_CONCURRENCY. Default is unchanged.

Why

Each concurrency slot polls on its own, so an idle World runs about queueConcurrency × 2 job-fetch UPDATEs per second. With log_statement = mod every idle poll lands in the Postgres log. Lowering queueConcurrency isn't a safe fix because it also caps parallel steps and can deadlock parent→child polling. This knob trades pickup latency for idle DB load instead.

Changes

  • config.ts / index.ts: new pollInterval option read from WORKFLOW_POSTGRES_POLL_INTERVAL_MS. The existing max-pool-size parser is generalized to getPositiveIntEnv(name) and used for both.
  • queue.ts: pollInterval: config.pollInterval ?? 500.
  • README and docs (configuration/worlds.mdx, worlds/v5/postgres.mdx) document the option and env var.
  • Test covering the default and the override. Patch changeset.

Testing

tsc --noEmit passes. The world-postgres unit tests pass (41/41). Integration tests (testcontainers) were not run.

Closes #4354

@cwdx
cwdx requested a review from a team as a code owner September 24, 2026 07:28
@changeset-bot

changeset-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b6094a

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 Sep 24, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@VaguelySerious

Copy link
Copy Markdown
Member

@cwdx Commits must have a verified signature for me to merge this. Please address

cwdx added 2 commits October 1, 2026 09:36
Add pollInterval to PostgresWorldConfig and read
WORKFLOW_POSTGRES_POLL_INTERVAL_MS in createWorld, matching the existing
WORKFLOW_POSTGRES_WORKER_CONCURRENCY pattern. queue.ts now uses
config.pollInterval ?? 500 instead of a hardcoded 500ms, so deployments
can trade job-pickup latency for idle Postgres load. Default behavior is
unchanged.

Each of the queueConcurrency workers polls independently at this
interval when idle; LISTEN/NOTIFY does not replace that polling, only
wakes a worker sooner for a newly enqueued job.

Closes vercel#4354

Signed-off-by: Chris Wijnia <ccwijnia@gmail.com>
…erval

Signed-off-by: Chris Wijnia <ccwijnia@gmail.com>
@cwdx
cwdx force-pushed the world-postgres-poll-interval branch from 50f1f21 to 3b6094a Compare October 1, 2026 01:39
@cwdx

cwdx commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Both commits are now SSH-signed (Verified) and signed off, and DCO passes. I rebased onto the main commit you had merged, so the code is unchanged. The remaining red checks are the Vercel deploys that need team authorization for my fork.

@VaguelySerious
VaguelySerious merged commit 479a78d into vercel:main Oct 1, 2026
119 of 184 checks passed
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Backport to stable failed for 479a78d due to a workflow error (backport job run).

This is usually an infrastructure problem (e.g. the configured AI model could not be found, an AI Gateway error, or an opencode crash) rather than a merge conflict. Check the job logs linked above for details.

Once the underlying issue is fixed, re-run the Backport to stable workflow manually via workflow_dispatch and paste this commit SHA into the ref input:

479a78d28f5c1168479e56a7791ea5de70730098

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.

world-postgres: pollInterval is hardcoded to 500 ms, so an idle World polls Postgres concurrency × 2 times per second

2 participants