Repository navigation
fix(demo): keep a demo in use and serialise boots - #47
Merged
Merged
Conversation
A deploy runs the new container beside the live one on the same database. Each boot's reset dropped the schema under the other: on 2026-10-16 the new container's operator seed found no Operator table and the deploy failed. prepare-demo replaces reset-demo and holds a Postgres advisory lock through reset, migrate and both seeds, so boots run one after the other. The reset now keeps a demo with activity in the last DEMO_RESET_IDLE_MINUTES (default 10): waking from sleep still starts fresh, a deploy beside a demo in use keeps it, and a second boot sees the first one's seed. The image smoke now starts two containers at once on one database; without the lock it fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
The deploy of
dab06b6failed at boot. Render's zero-downtime deploy ran the new container beside the live one, both on the same Neon database, and each boot's reset (#42) dropped the schema under the other:The site stayed up on the previous version and reseeded, but every deploy risked it. My #42 tests only ever ran one container.
What
prepare-demo.tsreplacesreset-demo.ts: under one Postgres advisory lock (single connection), reset if idle, migrate, seed the operator and the scenario. Boots now run one after the other.resetDemoDatabase(db, idleSince)returnsempty | kept | reset: a demo with audit activity in the lastDEMO_RESET_IDLE_MINUTES(default 10) is kept. Waking from sleep (15+ idle minutes) still resets; a deploy beside a demo in use keeps it; a second boot sees the first one's seed. All earlier guards stay.deploy/start.shruns it before starting the processes.scripts/deploy-image-smoke.shnow starts two containers at once on one database (oneempty, onekept, both serving, 40 labs once), then a third past the idle threshold mustreset.Verified
empty empty; with it, passes (147 MB).Known limit
A deploy during an idle stretch (no activity for 10 minutes) still resets under the old container, which sees missing tables for seconds while it is being replaced. Acceptable for a demo; recorded in GAPS and AGENTS.
After merge this is also the first commit under
checksPass: Render should start the deploy only after CI passes.🤖 Generated with Claude Code