Skip to content

chore(deps): PostgreSQL 18 with an automatic, non-destructive upgrade from 17 - #97

Merged
Yoshiofthewire merged 2 commits into
masterfrom
chore/postgres-18
Nov 25, 2026
Merged

Yoshiofthewire merged 2 commits into
masterfrom
chore/postgres-18

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

In one line: the bundled PostgreSQL (--profile postgres) is now 18.7. An install that ran 17 is moved by itself on the next up, and its 17 data is kept.

What changed

  • docker-compose.yml: postgres runs postgres:18.7-alpine3.24@sha256:0115267a… on a new postgres volume at /var/lib/postgresql. 18 refuses the old /var/lib/postgresql/data mount, so a plain image bump would crash-loop.
  • A new one-shot postgres-17-dump service (17.12 by digest, network_mode: none, same profile) dumps the old pgdata volume once. The 18 service runs the kit's restore as its entrypoint before the stock one. pgdata is only read and never removed.
  • scripts/postgres-17-to-18.sh is the shared Ky kit, byte-identical (sha256 29926441…, the 14:49 kit with the live-17 refusal). The script reaches the container by a ./scripts/…:ro bind mount, because operators run compose from a clone (INSTALL.md).
  • New scripts/test-postgres-17-to-18.sh, run in the CI docker job, drives this repo's real compose file. It seeds 17 with the previous compose file (dd87863), then proves:
    • the dump refuses beside a live 17 and writes nothing;
    • the move to 18 by up -d over the running 17 stack, with rows, a large object, the C collation, and logins for postgres and a second role by password over the compose network (a wrong password is refused);
    • rollback to 17 on the kept volume;
    • a rerun is a no-op;
    • a bad dump never yields a cluster, over 3 starts;
    • a fresh install initialises 18.
  • A new Go guard (TestComposePostgres18UpgradesFrom17) pins both digests, the mounts, the dump one-shot and the script's checksum. Other changes:
    • CI's postgres service is on 18 (pinned);
    • Dependabot ignores postgres majors for docker and github-actions;
    • operator note in docs/CONFIGURATION.md, plus a CHANGELOG entry.

Review this

  • docker-compose.yml: the two services and the volume split. A wrong mount or OLD/NEW path either strands the 17 data or starts an empty 18.
  • scripts/test-postgres-17-to-18.sh: the proof. Check that it really uses the previous compose file and asserts on password logins from outside the container. Inside the container 127.0.0.1 is trust.
  • Safe to skip: scripts/postgres-17-to-18.sh (the shared kit, reviewed in ky-postgres-18), Makefile comment, CHANGELOG.

Checked

  • Compose test PASS on Major (34 s once it has a slot).
  • Mutations of the compose test:
    • against a plain image bump of the old compose, it fails with "18 did not start after the move";
    • with the v1 kit script, it fails with "dump ran beside a live 17".
  • Guard mutations: the plain bump fails the Go guard, and so does a one-line edit to the vendored script.
  • SQLite race suites, normal and fips, plus gofmt, go mod tidy/verify and vet: PASS on k81.
  • Go race suite against a local PostgreSQL 18.7 container, normal and fips: PASS.
  • shellcheck scripts/*.sh passes with no exclusions; docs/check-strong-crypto-compose.py passes.

Not checked

  • The frontend, which is unchanged.
  • Browser tests and govulncheck, which this change doesn't touch. CI runs them.
  • Upgrade time on a large database. Only a 20,000-row seed was measured.

Decided for you

  • The new volume is named postgres. The old pgdata stays declared, so fresh installs also get an empty, unused pgdata volume.
  • The postgres service still has no healthcheck, because it had none before. The app still fails its start and restarts until postgres accepts connections, as before.
  • The docker CI job's timeout goes from 10 to 15 minutes.
  • Both postgres services get stop_grace_period: 2m (kit v2 rule), so 17 and 18 shut down cleanly.

You need to: nothing to merge it. Operators who use --profile postgres should read PostgreSQL 17 to 18. The move needs about twice the 17 data in free disk, and removing pgdata afterwards is their choice.

Detail

Upgrade flow, on docker compose --profile postgres up -d

  1. postgres-17-dump (17 image, no network) mounts pgdata at /var/lib/postgresql/data and postgres at /pg18. It skips when the move is done or there is no 17 data. Under Compose v5.7.0, up over a running 17 stack stops 17 first. It refuses when 17 still appears to be running (postmaster.pid) or there is less than 2× the data in free space. Otherwise it starts 17 on a private socket and writes pg_dumpall to upgrade-from-17/dump.sql atomically.
  2. postgres (18) waits for the dump with service_completed_successfully. Its entrypoint restores the dump into 18/docker.part, keeps the 17 roles and password hashes, renames the result to 18/docker and execs the stock entrypoint with postgres. A failed restore exits non-zero, restart: unless-stopped retries it, and no cluster appears.

Verification record (Major, 2026-11-25)

  • kslot bash scripts/test-postgres-17-to-18.sh: PASS: docker-compose.yml moves 17 to 18; rollback, rerun, bad dump and fresh install hold, on kit a800e026 and again on 29926441.
  • NEW_COMPOSE=docker-compose.bump.yml (the old file with only the image swapped to 18): FAIL: 18 did not start after the move, rc 1.
  • kjob (k81, exit 0): sqlite normal PASS, sqlite fips PASS.
  • The same test with the v1 kit (a800e026): FAIL: dump ran beside a live 17, rc 1.
  • The PG18 suite ran under kslot, with a throwaway postgres:18.7-alpine3.24@… container (server_version 18.7) removed by a trap. A first run with a long TMPDIR failed 2 installer tests on the 107-byte Unix socket limit, which is environment, not Postgres. With TMPDIR=~/.k: PG18 normal: PASS, PG18 fips: PASS.

PostgreSQL 18 behaviour changes: this repo declares no ON DELETE RESTRICT and never matches SQLSTATE 23503. It sets no MD5 passwords and has no COPY … CSV import.

🤖 Generated with Claude Code

… from 17

The bundled postgres moves to 18.7 (pinned by digest) on a new `postgres`
volume mounted at /var/lib/postgresql. A one-shot postgres-17-dump service
(17.12, no network) dumps the old `pgdata` volume once; the 18 service runs
the shared kit's restore as its entrypoint. `pgdata` is only read and kept.

- scripts/postgres-17-to-18.sh: the Ky kit, byte-identical (sha256 29926441…)
- scripts/test-postgres-17-to-18.sh: seeds 17 with the previous compose file,
  then proves the move by `up` over a running 17, the live-17 refusal,
  rollback, rerun, bad dump and fresh install; run in
  the docker CI job
- deploy_test: guards the digests, mounts, dump one-shot and script checksum
- CI postgres service on 18; Dependabot ignores postgres majors
- stop_grace_period 2m on postgres and the dump one-shot
- docs: operator note in CONFIGURATION.md, CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
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 detected


Advisory only: this comment never gates the pull request.
gpt-6.1-sol using pr-agent on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail 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-kypulse-server-97, 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

@Yoshiofthewire

Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Note

🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire

The "Ineffective wait" note doesn't hold: read -rt 1 <> <(:) waits a full second on each attempt.

<> opens the process-substitution pipe read-write, so the reader holds a write end too. That means read never sees EOF and returns only when -t 1 times out. Measured with bash on the Linux hosts we run this on:

$ TIMEFORMAT=%R; time (for i in 1 2 3; do read -rt 1 <> <(:) || true; done)
3.003

So the loops allow about one second per attempt, as intended. That gives the ~180 s budget the note expects. A plain <(:) without <> would behave as the note describes.

The read -t on a read-write process substitution did wait a second, but it took a
paragraph to show it. A plain sleep says the same thing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire
Yoshiofthewire merged commit 814e91f into master Nov 25, 2026
23 checks passed
@Yoshiofthewire
Yoshiofthewire deleted the chore/postgres-18 branch November 25, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant