docs: document ZERO_APP_ID replication slot pitfall for local dev#276
Open
Sriketk wants to merge 3 commits intorocicorp:mainfrom
Open
docs: document ZERO_APP_ID replication slot pitfall for local dev#276Sriketk wants to merge 3 commits intorocicorp:mainfrom
Sriketk wants to merge 3 commits intorocicorp:mainfrom
Conversation
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>
|
@Sriketk is attempting to deploy a commit to the Rocicorp Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
Running
zero-cachelocally against the same Postgres database as a deployed instance silently crashes production. The local instance callspg_terminate_backendto 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 ifZERO_UPSTREAM_DBpoints 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_IDlocally (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 theApp IDsection explaining the pitfall and the fix.deployment.mdx: Added a new## Local Development Against a Shared Databasesection at the end with a concrete.envsnippet.Context
Discovered and debugged in a production incident where
bun dev(viaturbo dev) was running a local zero-cache workspace package pointed at production Postgres, causing the Railway-deployed zero-cache to crash repeatedly overnight.