Repository navigation
fix(zbugs-swift): start Postgres again when it stops in a kept backend - #124
Merged
Merged
Conversation
zero-cache retries while Postgres refuses connections and catches up once it answers, so the restart from #120 never fires when Postgres is stopped, and Docker's restart: always leaves a container that docker stop stopped alone. With ZBUGS_PG_START, a kept backend runs that command once Postgres has missed three checks 10 seconds apart. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev>
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.
A kept zbugs-swift backend (
ZBUGS_KEEP=1) now starts Postgres again when it stops. SetZBUGS_PG_STARTto a command that starts it, for exampledocker compose -f apps/zbugs/docker/docker-compose.yml start. The backend runs it once Postgres has missed three checks 10 seconds apart, and again after each further three. This changes zbugs-swift only, so there's no changeset.Cause
On tmm's Mac, zbugs was down from Nov 9 at 17:18 EST until about 13:33 the next day.
fast shutdown request, which is whatdocker stopsends to the postgres image. That happened at 22:18:49 UTC on Nov 9, and again at 05:34:02 UTC on Nov 10, 8 s afterrestart: alwayshad started them. Nothing restarted them after the second stop. Docker'srestart: alwaysonly restarts a stopped container when Docker itself restarts, and Docker didn't restart until someone randocker startby hand.We don't know who sent the stops. No Amp thread on the Mac ran Docker commands at either time, and tmm's shell history has none. The fix doesn't depend on that.
Reproduction and checks
These ran in an orb with a local Postgres on 6434, server.ts with
ZBUGS_KEEP=1, andpg_ctl -m fast stopstanding in fordocker stop.OKwith no restart, and zbugs'BackendTests(log in, create an issue and a comment) passed.ZBUGS_PG_STARTset topg_ctl … start:OK, andBackendTestspassed.ZBUGS_PG_START failed: …. It was retried after three more misses and succeeded once the directory was back.oxfmt --checkandoxlint --type-awarepass on the changed files.ZBUGS_KEEP, so it's unaffected.After merge
On tmm's Mac,
~/.zbugs-swift/start.shgetsZBUGS_PG_START='docker compose -f apps/zbugs/docker/docker-compose.yml start'. Compose names the projectdockerafter the file's directory, which is the project those two containers belong to.startonly starts existing containers; it never recreates them.