Repository navigation
chore(deps): PostgreSQL 18 with an automatic, non-destructive upgrade from 17 - #126
Merged
Merged
Conversation
… from 17 The bundled PostgreSQL (base postgres profile and the replica overlay) moves to 18.7, pinned by digest, on a new volume mounted at /var/lib/postgresql. On the next `docker compose up`, a networkless postgres-17-dump one-shot (17 image) dumps the old volume once and the 18 service's entrypoint restores it before its first start; the 17 volume is kept for rollback. Both steps are the shared Ky kit, vendored byte for byte as scripts/postgres-17-to-18.sh. CI runs the Go suite on PostgreSQL 18 and gains postgres-upgrade, which seeds real 17 data with the previous compose files and proves the upgrade, rollback, rerun, a bad dump and a fresh install. The replica guard pins the images, the mounts, the one-shot and the kit's checksum. Dependabot ignores postgres major bumps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
PR Reviewer Guide 🔍Here are some key observations to aid the review process: ⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵🧪 PR contains tests⚡ No major issues detectedAdvisory only: this comment never gates the pull request. |
Member
Author
Security review - clearedDetail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-ky-server-base-126, where it is readable by the operator and expires seven days after the last post. gpt-6.1-sol using security-audit on behalf of Yoshi |
Member
Author
Autonomous review - 1/1 personas cleared
Merging remains a human decision; this bot never approves. gpt-6.1-sol using security-audit on behalf of Yoshi |
…utside Re-vendors the shared upgrade kit (sha256 29926441...): the dump one-shot now refuses while postmaster.pid is in the 17 data, because PostgreSQL's own lock check cannot see a 17 server in another container and would let a second postmaster start on the data. The kit also carries its own shellcheck source directive, so the repo .shellcheckrc goes. The upgrade test now checks passwords from a second container (inside the server initdb trusts 127.0.0.1, so a wrong password passed) and requires a wrong one to be refused; upgrades over the running 17 as an operator would; and requires a hand-run one-shot beside a live 17 to refuse and write nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 17 that Compose SIGKILLs mid-shutdown leaves postmaster.pid, which kit v2's dump now refuses. Both PostgreSQL services get stop_grace_period: 2m, and the compose guard asserts it for the base profile and the replica overlay. The upgrade test now asserts 17 is still running when `up -d` starts and that the one-shot logged its dump, so the running-stack path is proven for this repo's files, not just inferred from the restore. Docs and CHANGELOG name the grace period. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ruleset requires a check by that exact name; renaming the job to "Go tests (PostgreSQL 18)" left the required check unreported, so the PR could never merge. The version lives in the pinned image, not the name. 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.
In one line: The bundled PostgreSQL is now 18. An existing 17 database upgrades itself on the next
docker compose up, and the 17 volume is kept for rollback.What changed
--profile postgresservice and the replica overlay runpostgres:18.7-alpine3.24, pinned by digest. Before, the base file used an unpinned17-alpine. Data now lives in a new volume mounted at/var/lib/postgresql:postgres, orpostgres-replicaswith the overlay.postgres-17-dump, runs once onup. It uses the 17 image, has no network, and dumps the oldpgdataorpgdata-replicasvolume. The 18 service then restores that dump before its first start. The cluster only appears once the restore has finished. Nothing deletes or rewrites the 17 volume.scripts/postgres-17-to-18.sh. The compose files mount it from the checkout, the same way the overlay already mountsdeploy/replicas/haproxy.cfg.postgres-upgrade, added topublish.needs. It runsscripts/test-postgres-17-to-18.sh baseandreplicas, which create real 17 data with the previous commit's compose files and then run the current ones.check-replicas-compose.pynow pins the 18 and 17 digests, the/var/lib/postgresqlmount, the one-shot's settings, and the kit's checksum and mode 755.dockerandgithub-actions.docs/REPLICAS.md#postgresql-18-upgrade(what happens, disk space, time, rollback, manual clean-up), plus a README pointer and CHANGELOG notes.Review this
docker-compose.yml(postgres-17-dumpandpostgres, lines 86–131): the order of the upgrade and which volume each service mounts. A wrong mount here is what could reach user data.docker-compose.replicas.yml(lines 40–71): the overlay resets the one-shot's profile and swaps in its own volumes. The healthcheck getsstart_period: 1hso a long restore doesn't fail the stack.docs/REPLICAS.md, the Rollback bullet: if 17 takes writes after a rollback, the 18 volume has to be removed by hand before upgrading again.scripts/postgres-17-to-18.sh. It is kit v2 verbatim, sha25629926441…5ea2b571, and the guard enforces that.Checked: see Kit v2 below for what ran at the new head. The replica e2e suite and the smoke test run in CI only.
Not checked: a large real database (restore time is measured only on 50,000 rows), Docker setups other than local volumes, and whether
stop_grace_period: 2mever matters in practice (see Kit v2).Decided for you
./scripts/postgres-17-to-18.shrather than a composeconfigs:entry. Operators already run compose from a checkout, and the overlay already bind-mounts the HAProxy config.fed0fb3(PREV), the last master commit that ran 17. It doesn't useorigin/master, because after the merge that would point at the 18 files.Kit v2 (bug fix pushed to this PR after it went green)
Kit v1, which the first head (
0be0bb9) vendored, had a real bug. Its dump could start a second postmaster on 17 data that another container was still running. PostgreSQL's own lock check misses this:postmaster.pidnames PID 1 of the other container's PID namespace, and inside the dump container that PID looks like the dump's own grandparent. Two postmasters on one data directory can corrupt the 17 data, which this PR promises never to touch. Because this is a bug fix, it goes on this PR rather than a stacked one.scripts/postgres-17-to-18.shis re-vendored as kit v2, sha2562992644109716cd34297fbcb76eba8907f4a5e3031a12c05aade010e5ea2b571. The one-shot now refuses whilepostmaster.pidexists. Kit v2 carries its own# shellcheck source=/dev/null, so the repo.shellcheckrcis deleted.postgresservice andpostgres-17-dumpgetstop_grace_period: 2m. If Compose SIGKILLs a 17 halfway through shutdown,postmaster.pidstays behind and v2 refuses the dump.check-replicas-compose.pyasserts the 2m on both services, for the base profile and for the overlay.docker compose run --rm --no-deps postgres-17-dumpwhile 17 is still up. It must refuse with thepostmaster.pidmessage and write no dump.up -dagainst the running 17 stack, with nodownfirst. The test asserts that 17 was running, that the one-shot loggeddumped, and that 18 restored the rows.docs/REPLICAS.mdand the CHANGELOG describe the refusal, how to recover after a crash, and the stop grace period.chore/postgres-18was fast-forwarded to plover's698049d(re-vendor plus password fix), withcf40705(stop grace, running-stack assertions, docs) on top. The branch already contains master atfed0fb3.scripts/test-postgres-17-to-18.sh basePASS (base): live 17 refused, upgrade over a running 17, rollback to 17, rerun, bad dump, fresh installscripts/test-postgres-17-to-18.sh replicasPASS (replicas): …(same cases)a800e026…)FAIL (base): dump ran beside a live 17 serverFAIL (base): a wrong password logged in: the password checks prove nothingstop_grace_period: 1ma SIGKILLed 17 leaves postmaster.pid, which the dump refusesstop_grace_period: 0s, upgrade testcheck-replicas-compose.py,shellcheck scripts/*.sh-race -p 2 -count=1, SQLite (kjob on k80)-race -p 2 -count=1andGODEBUG=fips140=on, on a throwawaypostgres:18.7-alpine3.24@sha256:0115…(server 18.7)make ci(notes-check, tidy-check, lint, test-race, test-web, audit-web, smoke), Node 26.13.1Local CI checks passed: 37 web tests, npm audit gate passed, smoke test passed. Some Go packages came from cache in its race run; the kjob and PG18 runs above used-count=1on the same codeThe running-stack case passes on v1 and on v2. It cannot fail on v1, because Compose stops 17 before the dump with either kit. Its job is to prove that v2's new refusal does not block the normal
uppath for this repo's files.You need to: nothing before merging. Operators pick up the upgrade on their next
up. Removing the 17 volume afterwards is their choice and is documented.Detail
Verification at the first head
All runs are on Major, at head
0be0bb9cd3a4(kit v1). The current head's results are in Kit v2 above.scripts/test-postgres-17-to-18.sh basePASS (base): upgrade, rollback to 17, rerun, bad dump, fresh install(22 s)scripts/test-postgres-17-to-18.sh replicasPASS (replicas): …FAIL (base): 18 did not start after the restore; the guard fails tooFAIL (replicas): 18 did not start after the restorerestoreentrypointFAIL (base): no restore ran; guard:PostgreSQL does not restore a 17 dump firstdiffers from the upgrade kit/is not mode 755go mod verify, vet, build,go test -race -p 2+GODEBUG=fips140=on(SQLite)postgres:18.7-alpine3.24@sha256:0115…PostgreSQL 18.7 on x86_64-pc-linux-musl)KY_E2E_COMPOSE=1 go test ./e2e)Compose replicas and failover: pass (4m2s). The local run on Major could not create its replica network: another project's network holds172.31.0.0/16. PostgreSQL 18 had initialised before that pointPostgreSQL 17 to 18 upgrade (Compose)(PASS (base)andPASS (replicas)in its log) andGo tests (PostgreSQL 18)End-to-end smoke testpassednpm ci,npm test,npm run build,git diff --exit-code web/dist,npm run auditweb/distclean, audit gate passedtest_ky_init.py,check-no-binaries.sh,check-strong-crypto-compose.py,check-replicas-compose.py,make notes-check,reuse lintWhat the upgrade test does
git show fed0fb3:docker-compose.yml(anddocker-compose.replicas.ymlfor the replicas run), starts 17, and seeds:up -d postgresover the running 17. The one-shot dumps, then 18 restores. It then checks:data_directory=/var/lib/postgresql/18/docker;B,a,é. At the first head this check ran inside the server container and proved nothing; kit v2's test fixes it;PG_VERSION=17.already doneand nothing is restored again.18/dockerever appears.down -v: the one-shot logsnothing to moveand 18 runs a plain initdb.PostgreSQL 18 behaviour changes checked
No Go code matches SQLSTATE
23503/23001. No migration declaresRESTRICT, sets an MD5 password or usesCOPY … CSV, so the 18 incompatibility list does not apply.Not changed
docker-composeecosystem here, so it does not touch the compose pins.🤖 Generated with Claude Code