Skip to content

docs: document ZERO_APP_ID replication slot pitfall for local dev#276

Open
Sriketk wants to merge 3 commits intorocicorp:mainfrom
Sriketk:docs/zero-app-id-local-dev-replication-slot-pitfall
Open

docs: document ZERO_APP_ID replication slot pitfall for local dev#276
Sriketk wants to merge 3 commits intorocicorp:mainfrom
Sriketk:docs/zero-app-id-local-dev-replication-slot-pitfall

Conversation

@Sriketk
Copy link
Copy Markdown

@Sriketk Sriketk commented Apr 7, 2026

Problem

Running zero-cache locally against the same Postgres database as a deployed instance silently crashes production. The local instance calls pg_terminate_backend to steal the exclusive replication slot, which causes the deployed zero-cache to exit. This also applies to monorepo dev scripts (e.g. turbo dev) that start zero-cache as a workspace package if ZERO_UPSTREAM_DB points at a shared database.

This behavior is not documented anywhere in the current docs, making it very hard to debug (the deployed instance exits cleanly with code 0, not with an obvious error).

Fix

Set a distinct ZERO_APP_ID locally (e.g. ZERO_APP_ID=zero_dev). Zero uses the App ID to name the Postgres replication slot, so different IDs = independent slots that never conflict. No separate dev database needed.

Changes

  • zero-cache-config.mdx: Added a warning callout under the App ID section explaining the pitfall and the fix.
  • deployment.mdx: Added a new ## Local Development Against a Shared Database section at the end with a concrete .env snippet.

Context

Discovered and debugged in a production incident where bun dev (via turbo dev) was running a local zero-cache workspace package pointed at production Postgres, causing the Railway-deployed zero-cache to crash repeatedly overnight.

Running zero-cache locally against the same Postgres as a deployed
instance (e.g. via a monorepo dev script like turbo dev) causes the
local instance to steal the exclusive replication slot, crashing
production. Setting ZERO_APP_ID=zero_dev locally gives each environment
its own slot so both can run simultaneously without conflict.

Added a warning callout to the App ID section in zero-cache-config and a
new "Local Development Against a Shared Database" section in deployment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

@Sriketk is attempting to deploy a commit to the Rocicorp Team on Vercel.

A member of the Team first needs to authorize it.

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