Repository navigation
chore(deps): PostgreSQL 18 with an automatic, non-destructive upgrade from 17 - #152
Merged
Merged
Conversation
… from 17 Matrix's Postgres moves to 18.7 (pinned by digest). A 17 stack upgrades on its next `docker compose up -d`: the one-shot postgres-17-dump (17.12 image, no network, read-only root) dumps pgdata/ once into upgrade-from-17/, and the postgres service restores it into 18/docker on the same volume before the stock entrypoint runs. Both run scripts/postgres-17-to-18.sh, the suite's kit v2, byte for byte; it refuses to dump while postmaster.pid exists, and both services stop with a 2-minute grace so a clean stop removes it. The 17 data is never deleted or written; rolling back is the previous release's Compose files. - Dockerfile: postgresql18-client, so the app's pg_dump/pg_restore match. - Health pins regenerated (postgres 18.7); CI's Postgres suite runs on 18. - check-compose-matrix holds the layout, the one-shot, the kit's checksum and mode; the Podman overlay maps and labels the new bind. - scripts/test-postgres-17-to-18.sh (CI job postgres-upgrade) seeds 17 with the last 17 Compose files and proves the move with 17 running, a refused dump beside a live 17, passwords over the network, matrix-init re-runs and rotation, rerun, rollback, a bad dump, clean-up, a fresh install and a 17 backup restored on 18. - Operator note in docs/CHAT-SETUP.md "PostgreSQL 18". 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-kymessage-server-152, 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 |
The harness runs Compose with its scratch dir as the project directory and copied only compose/ and overrides/, so the kit bind (./scripts/postgres-17-to-18.sh) had no source and every leg failed at the stack step. Copy the script there too. 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: Matrix's database now runs PostgreSQL 18.7, and an existing 17 stack upgrades by itself on its next
docker compose up -d. Its 17 data stays untouched for a rollback.What changed
up, a new one-shotpostgres-17-dump(17.12 image, no network, read-only root) dumps the 17 data (pgdata/inmatrix-postgres) once. Postgres 18 restores that dump into18/dockeron the same volume, then starts normally. Nothing deletes or rewrites the 17 data.postgresql18-client, so backups usepg_dump/pg_restore18. Capsules taken on 17 still restore (tested).scripts/postgres-17-to-18.shis the suite's kit, vendored byte for byte (kit v2, sha25629926441…), andcheck-compose-matrix.shenforces that. It also holds the new layout and the locked-down one-shot.scripts/test-postgres-17-to-18.shon real 17 data. It is added torelease-image.yml's REQUIRED list.scripts/matrix-acceptance.shcopies the kit into its scratch project directory, besidecompose/. Compose resolves./scripts/postgres-17-to-18.shfrom there, so without the copy every acceptance leg and the KyCalendar suite failed atstack("bind source path does not exist").Review this
docker-compose.matrix.yml, thepostgres-17-dumpandpostgresservices. This is what runs on every operator's nextup. The dump mounts the volume at/v(OLD=/v/pgdata NEW=/v); 18 mounts it at/var/lib/postgresqlwith noPGDATA.scripts/test-postgres-17-to-18.shis the proof. Its password checks connect from a separate container onmatrix-db, because the stock image trusts 127.0.0.1 inside the server's own container. I reported that gap in the kit's own test on the suite board.probe.shmount, the CHANGELOG.Checked (on Major, Docker 29 and Compose 5.7)
check-compose-matrix,-podmanand-proxyandcheck-strong-crypto-compose.pypass. Dropping the kit bind's SELinux label fails the Podman check.matrix-acceptance.shagainst the real stack, stopped afterkyidentity(KyIdentity at CI's pinned8cf7cf9): PASS. Postgres 18 starts on a fresh volume through the kit, and Synapse, MAS and the app come up healthy. Without the copy, the same run fails atstackwith CI's exact error.shellcheckpasses overscripts/*.shwith no exclusions.go vetandgo test -racepass on SQLite and on PostgreSQL 18.7, exceptTestInstallerLiveActivationRolesAndSignedRevocation, which failed only because of the long temp path on Major ("setup socket path exceeds the 107-byte Unix limit"). Rerun with a shortTMPDIR: see below.Not checked
matrix-acceptanceafterkyidentity, and the KyCalendar suite: this PR's CI runs them.Decided for you
./scripts/postgres-17-to-18.sh, because operators run Compose from a git checkout (INSTALL.md). The release workflow publishes images only, no Compose bundle, and the Compose files already bind./compose/and./matrix/from the checkout. Soconfigs:would buy nothing. KyQuickStart ships its own template and must embed or carry the script.pgdata/postmaster.pidexists. The test shows a hand-runpostgres-17-dumpbeside a live 17 is refused and writes nothing, and it fails with the earlier kit. Both Postgres services getstop_grace_period: 2m, so a clean stop removes that file.docker compose exec postgres rm -r /var/lib/postgresql/pgdata /var/lib/postgresql/upgrade-from-17. It is the same volume, so there is nodocker volume rm..github/dependabot.ymlis unchanged: no configured ecosystem sees a Postgres image. Thedockerentry reads only the Dockerfile, there is nodocker-composeentry, andgithub-actionsdoes not bumpservices:images.You need to: nothing. The root thread merges once CI and the reviews are clean.
Detail
Images
postgres:18.7-alpine3.24@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71(Compose and the CI service).postgres:17.12-alpine3.24@sha256:f9cf3e1f0066f0eb0c48707d864f0ac5941e9ff454a072077d97a4d278d07d73.The upgrade test, step by step
init.sqlandkybackup-role.sqlon a 17 stack brought up with the Compose files ofd83af54(the last 17 master).pg_trgmindex.internal/backuptakes one (custom format, askybackup).18/dockerwith checksums on;Ccollation;mastrigram query works;synapse,mas,kybackupandpostgreslog in with their passwords from another container, and a wrong password is refused;kybackupcannot write;pgdata/PG_VERSIONis still 17.kybackup-role.sqlapplies. Rotation: the new password is refused untilrole-passwords.sqlis applied, then works.18/dockernever appears.pg_restore --list, a full read, and a restore withpgRestore's exact flags as the database owners all accept the 17 backup.Socket-test rerun:
TestInstallerLiveActivationRolesAndSignedRevocationpasses withTMPDIR=$HOME/.kgon SQLite and on PostgreSQL 18.7 (ok internal/api). The full-suite failure was the 107-byte socket limit on Major only.KyQuickStart (next worker): the Compose shape to copy.
postgres-17-dump:user: KY_MATRIX_UID:GID;entrypoint: [bash, /ky/postgres-17-to-18.sh, dump], envOLD=/v/pgdata,NEW=/v;network_mode: none,restart: "no",read_only,tmpfs /tmp,no-new-privileges,cap_drop ALL;matrix-postgres:/vand the script read-only.postgres:entrypoint: [bash, /ky/postgres-17-to-18.sh, restore],command: [postgres]; noPGDATA;matrix-postgres:/var/lib/postgresql,./matrix/postgresand the script;depends_on: postgres-17-dump: service_completed_successfully; healthcheckstart_period: 1h.selinux: zon the script bind.🤖 Generated with Claude Code