Repository navigation
chore(deps): PostgreSQL 18 with an automatic, non-destructive upgrade from 17 - #739
Merged
Merged
Conversation
… from 17 The replica overlay's database moves to postgres:18.7-alpine3.24. Its 18 image refuses a mount at /var/lib/postgresql/data, which is why the plain Dependabot bump (#734) never became healthy in ci-docker. An install on 17 moves on the next `up`. A one-shot postgres-17-dump (17 image, no network) dumps the kept kypost_pgdata volume once into the new kypost_postgres volume. The 18 service then restores that dump, renames it into place and starts. Both steps are the shared Ky kit, vendored byte for byte as scripts/postgres-17-to-18.sh. Nothing removes the 17 volume. scripts/test-postgres-17-to-18.sh seeds 17 with the previous commit's compose files, with 17 still running. It checks: - rows, both roles' passwords and the C/UTF8 locale survive on 18; - the previous compose files still start 17 on the kept volume; - a rerun does nothing; - a bad dump never yields a cluster; - the documented clean-up keeps 18 running; - a fresh install initialises. It runs in ci-docker. check-replicas-compose.py pins both images, the mounts, the one-shot and the kit's SHA-256. CI's Postgres service moves to postgres:18.7-trixie. Dependabot ignores postgres majors. 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: 4 🔵🔵🔵🔵⚪🧪 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-kypost-server-739, 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 |
CHANGELOG.md: keep both new entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit v1's dump could start a second postmaster on a 17 data directory another container still runs: PostgreSQL's own lock check cannot see across PID namespaces. Kit v2 (sha256 29926441...) refuses while postmaster.pid exists and carries its own shellcheck directive, so the repo-side SC1091 exclusion goes. Both PostgreSQL services get stop_grace_period: 2m, so Compose does not SIGKILL a 17 mid-shutdown and leave a postmaster.pid the dump refuses. check-replicas-compose.py asserts it and the new checksum. test-postgres-17-to-18.sh now: - checks passwords from another container on the database network, where pg_hba's scram line applies, and that wrong ones are refused; - runs the dump beside the live 17 and asserts it refuses, naming postmaster.pid, and writes nothing; - asserts the dump and restore ran on an `up -d` over the running 17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit v2 started the older 18 after a rollback to 17 and back, without what 17 wrote meanwhile. Kit v3 records 17's checkpoint at the dump and refuses once 17 has run since, naming two choices: move 17 again (rename 18/ and upgrade-from-17/) or keep 18 (delete source-checkpoint). The upgrade test now writes on 17 after a rollback and checks the refusal, both documented choices and the replaced 18 being kept. RUNNING.md describes the way back to 18 and that an exited postgres-17-dump is its finished state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit v3 kept its rollback checkpoint in upgrade-from-17/, so the documented clean-up (rm -r upgrade-from-17) broke every later start. Kit v4 keeps it at 18/moved-from-17.checkpoint, beside the 18 cluster. - Re-vendor the kit byte for byte and pin its new SHA-256. - The upgrade test uses the new marker for "keep 18", checks that the marker moves with 18.replaced, and gains steps 6 and 6b: after the dump is removed (17 kept), 18 still starts, and a rollback that writes on 17 is still refused on the way back. Removing the 17 volume is step 6c. - RUNNING.md: the new marker path; the dump clean-up is safe and keeps rollback; removing the 17 volume is a separate step. 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.
Supersedes #734.
In one line: the replica overlay's database is now PostgreSQL 18. An install on 17 moves by itself on the next
up, and its 17 volume is kept for rollback.What changed
up, a one-shotpostgres-17-dump(17 image, no network) dumpskypost_pgdataonce into the newkypost_postgresvolume. The 18postgresservice restores that dump, renames it into place and starts. Nothing deletes or writes the 17 data.scripts/postgres-17-to-18.sh. It is mounted from the checkout, as every other overlay file is.scripts/test-postgres-17-to-18.sh, run inci-docker. It drives the real compose files on real 17 data: the move, rollback, a rerun, a bad dump, the documented clean-up and a fresh install.check-replicas-compose.pynow pins both images, the mounts, the one-shot and the kit's SHA-256.postgres:18.7-trixie. Dependabot now ignores postgres major versions.Kit v2 (bug fix on this PR, allowed past the green-PR freeze)
dumpstep on a 17 data directory that another container still runs: PostgreSQL's own lock check cannot see across PID namespaces.scripts/postgres-17-to-18.shis now kit v2, byte-identical (sha2562992644109716cd34297fbcb76eba8907f4a5e3031a12c05aade010e5ea2b571; the guard pins it). v2 refuses whilepostmaster.pidexists and carries its own# shellcheck source=/dev/null, so CI's per-file SC1091 exclusion is gone: shellcheck is back toscripts/*.sh, as on main.postgresandpostgres-17-dumpgetstop_grace_period: 2m. Otherwise Compose SIGKILLs a 17 that is still shutting down, which leaves apostmaster.pidthe dump then refuses.check-replicas-compose.pyasserts this.test-postgres-17-to-18.shgains three things:docker compose run --rm postgres-17-dumpmust fail, namepostmaster.pid, write nothing into the 18 volume, and leave 17 serving;up -dover the running 17 stack (nodown) must log the dump and the restore;databasenetwork (loopback inside the server container is trust in the stock image), and a wrong password for each role must be refused, on the move and on a fresh install.docs/RUNNING.mdsays what the refusal means and what to do after a crash.mainis merged in (MH7: table-mode start checks and cross-host transport #738, ci: run CI and CodeQL on merge queue groups #740). The only conflict was CHANGELOG, where both entries are kept.Kit v2 checks (Major, Docker 29.9.3, Compose v5.7.0, head after the merge)
test-postgres-17-to-18.shpassed all steps, 1b included, in 5m40s underkslot.POSTGRES_HOST_AUTH_METHOD: trustto the 18 service fails step 2 ("a wrong password logged in"). The old in-container loopback check could not catch this.stop_grace_periodfails the guard.postgres:18.7-trixie(CI's digest; C, UTF8,max_connections=400),-race -p 2: every stores-leg package and all ofinternal/apipassed.go vet ./...+go test ./...passed. kjob found every K host busy, so it ran locally underkslot.ci-scriptsstep passed locally, includingshellcheck scripts/*.shandcheck-replicas-compose.py.TestReceivingServerAnswersForwardedCommandshit the socket path length limit (bind: invalid argument). It passed on SQLite and on 18 with a shorter TMPDIR.docker buildandcheck-replica-cutover.sh. They passed on 18 at the first head; CI'sci-dockerreruns them on this head.Kit v3 (bug fix on this PR, allowed past the green-PR freeze)
18/docker, said "already done" and started the older 18. What 17 wrote during the rollback stayed only inkypost_pgdata, invisible to the app.scripts/postgres-17-to-18.shis now kit v3, byte-identical (sha25665632931413f9ddca0bce3ad5a13cd7db70860156c402c8d40c027f3c16abf15; the guard pins it). After its clean stop of 17, the dump records 17's latest checkpoint inupgrade-from-17/source-checkpoint. On a laterup, if 17 has run since, it refuses and names two choices. Nothing is deleted either way. A v2 install with no checkpoint file takes the current checkpoint.upfails, the dump's log says 17 has run since the move, andpostgresis not running.compose runcommand (rename18/andupgrade-from-17/to.replaced). The row reaches 18, and the replaced cluster and dump are still there.uprefuses. "Keep 18" (RUNNING.md'srmofsource-checkpoint) is accepted and still holds on the nextup..replaceddirectories, and anExited (0)postgres-17-dumpis described as its normal finished state.scripts/AGENTS.mdis updated to match.Kit v3 checks (Major, head 131a2e7)
test-postgres-17-to-18.shpassed every step in 1m21s underkslot.all predefined address pools have been fully subnetted. Other workers' networks held the pools. The step-7downfixed it.18/renamed: fails at 3c ("18 did not start after moving again"). Both renames in the docs are needed.ci-scriptssteps passed locally:shellcheck scripts/*.sh;check-no-binaries.sh;check-replicas-compose.py(with the v3 checksum);docker compose config;check-strong-crypto-compose.py.docker build/check-replica-cutover.sh. No Go, frontend or relay file changed since e5c7434, where CI passed every job. CI reruns them all on this head.Kit v4 (bug fix on this PR, allowed past the green-PR freeze)
upgrade-from-17/source-checkpoint. After the documented clean-up (rm -r upgrade-from-17, with the 17 volume kept), every later start failed: the dump could not write the file into a directory that was gone.scripts/postgres-17-to-18.shis now kit v4, byte-identical (sha256195ae8684e34dd515158a88b1f76b918cf6e3f3c854ce83fe4fb190a5178cf06; the guard pins it). The rollback refusal works as in v3, but the checkpoint is now18/moved-from-17.checkpoint, beside the 18 cluster. Removing the dump keeps it, and renaming18/to move again takes it along.18.replaced/moved-from-17.checkpointis still there.upgrade-from-17/with the 17 volume kept, and 18 still starts.upthen refuses with the rollback message and 18 stays down. "Keep 18" is accepted.mvonce the dump is gone.18/moved-from-17.checkpoint.scripts/AGENTS.mdmatches.Kit v4 checks (Major, head b624e4a)
test-postgres-17-to-18.shpassed every step in 3m44s underkslot.ci-scriptsstep passed locally underkslot, includingshellcheck scripts/*.sh,check-replicas-compose.py(with the v4 checksum) and bothcompose configsteps.docker build/check-replica-cutover.sh. No file they cover changed since e5c7434, and CI passed every job at 131a2e7. CI reruns them all on this head.Review this
docker-compose.replicas.yml: the one-shot, the 18 entrypoint,depends_onand the 1 hstart_period. A mistake here can start 18 empty or leave the stack unhealthy during a long restore.uprefuses until the operator chooses "move 17 again" (rename two directories) or "keep 18" (delete18/moved-from-17.checkpoint). Check that the two commands and what each one loses read clearly. This is the one sharp edge for operators.Checked at the first head (a8bc990, kit v1; on Major, Docker 29.9.3, Compose v5.7.0)
test-postgres-17-to-18.shpassed all 7 steps (45 s), seeding 17 withcf5c3c80's compose files and leaving 17 running when the newupstarted.check-replica-cutover.shpassed end to end on 18 with a locally built image (INSTALL_OLLAMA=false). This is the step chore(deps): bump postgres from 17-alpine to 18-alpine #734 failed (postgres-1 is unhealthy)./var/lib/postgresql/data).postgres:18.7-alpine3.24(C, UTF8,max_connections=400) passed:ci-backend-postgresstores leg;internal/api.go vet+go test -race ./...on SQLite passed, run locally underkslotbecause every K host was busy.ci-scriptssteps passed locally, shellcheck included in the new per-file form.TestReceivingServerAnswersForwardedCommands: my TMPDIR made the socket path too long (bind: invalid argument). Passed on both backends with a shorter TMPDIR.TestNativeMailRelayCheckRuntime: hit its 30 s limit under load. Passed alone on 18.Not checked
Decided for you
dumpused to start a second postmaster beside a running 17. Kit v2 refuses instead (see Kit v2 above).You need to: nothing. Operators of the replica overlay need
git pullbefore the next upgrade; the script is mounted from the checkout.Detail
Images
docker-compose.replicas.ymlpostgrespostgres:17-alpine@sha256:526f86d9…postgres:18.7-alpine3.24@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71postgres-17-dump(new)postgres:17.12-alpine3.24@sha256:f9cf3e1f0066f0eb0c48707d864f0ac5941e9ff454a072077d97a4d278d07d73ci-backend-postgresservicepostgres:17@sha256:3b0cda93…postgres:18.7-trixie@sha256:c699303802144847d238196173655dbbecf7a96aeca1565f2b02eb671a1f0b6b(resolved withdocker buildx imagetools inspect)Volumes
kypost_pgdata(17 data) is mounted only by the dump, at/var/lib/postgresql/data.kypost_postgres(new) is mounted by 18 at/var/lib/postgresql, with no PGDATA, so the data lives in18/docker. The dump mounts it at/pg18.Upgrade test steps (
scripts/test-postgres-17-to-18.sh)git show cf5c3c80:docker-compose{,.replicas}.yml, fetched by SHA when missing. The seed is 50,000 rows, a second login role and C-ordered text.1b. With 17 up, a
runof the dump refuses onpostmaster.pidand writes nothing.up -d --wait postgreswhile 17 is still running (nodown). Then check:B,a,éstill sorts that way and the database isC,UTF8;/var/lib/postgresql/18/docker;PG_VERSION=17;3b. Back on the new files:
upfails, the dump says 17 has run since the move, and 18 is not running.3c. "Move 17 again" via RUNNING.md's rename command: 18 has 50,001 rows, and
18.replacedandupgrade-from-17.replacedare kept.up: the dump says "already done" and nothing is dumped or restored again.4b. 17 runs again, so
uprefuses. "Keep 18" (rmofsource-checkpoint) is accepted, and the nextupstill holds.18/docker.docker volume rm …_kypost_pgdata, thenrm -rof the dump): 18 restarts with every row.18/dockerwith the C locale.PostgreSQL 18 behaviour changes: no Go code matches SQLSTATE 23503 and no schema declares RESTRICT foreign keys, so the 23001 change does not apply. No MD5 passwords, no
COPY … CSVwith\..🤖 Generated with Claude Code