Skip to content

[Bug] The bundled pg_dump 18 caps the server major: no boot against Postgres 19, and the compose stack cannot follow #1431

Open

Description

@aw23edfr4

HealthLog version

1.48.4 (checked against 1.48.5 — unchanged)

Deployment type

Self-hosted (Docker) — the app image from GHCR, with its own Postgres rather than the
project's compose db.

What happened?

Two findings with one cause: the PostgreSQL client major in the image is also the highest
server major HealthLog can run against, and nothing says so.

1. A server on 19 takes the app down. The pre-migration dump runs the bundled pg_dump
18.6 against a 19.0 server, which aborts with a server version mismatch. docker-entrypoint.sh
then stops the boot — "not migrating without the dump", which is the right call — and the
container crashloops. The nightly dump and db-restore fail the same way, but those fail
quietly from an operator's seat: there have been no app-level dumps here since the server moved.

docs/ops/postgres-major-upgrade.md reads as if the major were the operator's choice for a
BYO install: "Installs that bring their own Postgres (Unraid, an existing database server) are
not touched: HealthLog runs on 16 and 18 alike, and the move there is yours to schedule."
In
fact the image caps it at the bundled major, and the cap does not bite when the database moves
— it bites at the next release that carries a migration. Here that was three hours later, which
is what made the cause hard to find.

2. The bundled stack cannot follow to 19 the way the file plans. docker-compose.yml mounts
the volume one level up "so the next major can sit beside this one in the same volume". The
official image refuses exactly that: docker_error_old_databases() collects every
/var/lib/postgresql/*/docker that holds a PG_VERSION and exits 1 before the server starts
(docker-library/postgres#1259). So a db bumped to 19 never becomes healthy, and db-upgrade,
which waits on its healthcheck, never runs. pg_upgrade --link, which that layout is for, needs
both majors' binaries in one image: the alpine images carry one each, and bridging it with a
glibc image would re-collate the existing text indexes.

I hit both on nine clusters on 2026-11-20, when an automerged postgres:18 → 19 bump went out
across them, and moved each with a logical dump/restore. HealthLog was the one that stayed down,
because of (1).

Expected behavior

  • A server major the bundled client cannot dump is either supported, or refused with a message
    that names both versions and the way out — rather than surfacing as pg_dump's mismatch line
    inside a boot abort three hours after the change that caused it.
  • The BYO freedom the docs describe and the ceiling the image sets agree with each other,
    whichever way that is resolved.
  • The bundled stack has a path to the next major that the official image allows.

Steps to reproduce

For (1):

  1. Start a postgres:19.0-alpine and point DATABASE_URL at it (any BYO setup does).
  2. Start an app release that carries a pending migration.
  3. The boot stops: pg_dump: error: aborting because of server version mismatch, followed by
    "HealthLog: ERROR — not migrating without the dump". node scripts/db-dump.mjs daily fails
    the same way on an already-migrated database.

For (2):

  1. On a stack whose postgres-data volume holds a populated Postgres 18, change db to
    postgres:19.0-alpine.
  2. docker compose up -d. The db container exits 1 with "there appears to be PostgreSQL data
    in: /var/lib/postgresql/18/docker", and db-upgrade stays queued behind the healthcheck.

Screenshots / other logs

pg_dump: error: server version: 19.0 (Debian 19.0-1.pgdg13+1); pg_dump version: 18.6 (Debian 18.6-1.pgdg13+1)
pg_dump: error: aborting because of server version mismatch
HealthLog: ERROR — not migrating without the dump. Free disk space or fix the error above and start again.
HealthLog: to migrate without a dump this once, set DB_BACKUP_BEFORE_MIGRATE=false.

Pre-flight checks

  • I confirmed this is not a duplicate of an existing issue.
  • I redacted any secrets, tokens, or personal data from logs.

Offer

The client half of the fix is up as a pull request: it stands on its own, fixes (1) for
every install that brings its own database, and forces nothing on anybody, because a client
reads its own major and older. Close it without ceremony if you would rather have the whole
move in one change, or none of it yet.

The bundled half — (2) — I have deliberately not written, because its shape depends on
answers that are yours: without a second volume the 19 server cannot come up at all past
docker_error_old_databases, and I have no way to prove a volume move here. Say which way you
want it and I will send it.

What the whole change would be:

  • pgclient to postgres:19.0-trixie, digest-pinned, and the 18 paths, the ld.so.conf entry,
    PATH and both --version build checks with it.
  • db to postgres:19.0-alpine, plus an 18 → 19 move modelled on the 16 → 18 step that is
    already there: a separate volume for 19, the 18 volume mounted read-only, the dump streamed in
    one transaction, every table's row count compared, --analyze-in-stages, a marker on the old
    volume, and app gated behind it. The separate volume is what gets past
    docker_error_old_databases without pg_upgrade — the same shape the 16 → 18 step uses, and
    it keeps the old volume as the way back.
  • src/__tests__/runtime-package-pins.test.ts (the client/database agreement and the COPY
    path), src/__tests__/database-pin-is-watched.test.ts (it asserts exactly two postgres images
    in the compose file), the postgres:18-alpine services in e2e.yml and
    post-publish-verify.yml, scripts/compose-dr-drill.sh,
    scripts/compose-db-upgrade-check.sh, docs/contributing/benchmarks.md, the docs
    (postgres-major-upgrade.md, getting-started.md, truenas.md, CONTRIBUTING's
    "PostgreSQL 16+"), and the compose comment that promises the same-volume layout.

Three things I would rather you decided than guessed at:

  1. Timing, and whether the two halves ship together. The 19.0 images were published on
    2026-11-20. Bundling a major that new is a different risk appetite from the one the pin
    comments describe. The halves are separable: the client bump alone fixes (1) for every BYO
    install and forces nothing on anybody, because a client dumps its own major and older. Its
    cost is that it puts pg_restore 19 against the bundled 18 server in the disaster-recovery
    path, which is the direction the present rule deliberately avoids. If you would rather bundle
    19 after 19.1 in February, the client half still stands on its own in the meantime.
  2. The 16 → 18 hop. Keep both steps in the file (16 → 18 → 19), or declare that installs
    from v1.45 and earlier update through a 1.46–1.48 release first and drop the 16 step, as its
    comment already anticipates?
  3. A guard, regardless of 19. Should the dump compare server_version_num against
    pg_dump --version before it runs and say so plainly? That is what turns the next major from
    a mismatch line in a crashloop into one sentence an operator can act on — and it is worth
    having even if the version bump waits.

Activity

  1. MBombeck commented on Nov 22, 2026

    @MBombeck
    Owner

    Thank you for the careful report, and for #1432, which is merged. The client half ships with 1.49.0: the image carries the PostgreSQL 19 client tools, so an install that brings its own server on 19 dumps, migrates and boots again, and the upgrade guide now names the ceiling.

    The second half, moving the bundled db to 19 with a path the official image accepts, is a larger change to the compose stack and its upgrade step. I'm leaving this issue open for that part.

  2. MBombeck commented on Nov 23, 2026

    @MBombeck
    Owner

    @aw23edfr4 The client half is out now in 1.49.0: https://github.com/MBombeck/HealthLog/releases/tag/v1.49.0

    The image carries the PostgreSQL 19 client tools, so a server on 19 gets its pre-migration dump and its nightly dumps again, and 16 and 18 work as before. Thanks again for tracking it down and for sending the fix with it. The second half, moving the bundled db to 19, is still open here.

  3. MBombeck commented on Nov 26, 2026

    @MBombeck
    Owner

    @aw23edfr4 Sorry for leaving your three questions open. Here is where things stand on main and on the 1.50 branch today.

    1. Timing. The bundled db stays on postgres:18.6-alpine in 1.50.0 (Saturday, 5 December). Only the client moved to 19, through your #1432, so the two halves are already separate. I don't have a date for the bundled move yet. I'm not keen on bundling a major before its first minor release, so 19.1 in February is the earliest I'd look at it.

    2. The 16 to 18 step. It is still in docker-compose.yml on both branches, unchanged, and nothing removes it for now. I lean towards keeping it in front of a 19 step rather than telling old installs which release they have to stop at, but that isn't decided.

    3. A version check before the dump. It doesn't exist yet. The dump records server_version_num in its manifest, but nothing compares it with pg_dump --version before the run, so the next major after 19 would fail exactly the way you saw it: a mismatch line inside a boot abort. That is a real gap and worth closing whether or not the bump waits. I can't name a release for it yet, and I'll update this issue when it's on a branch.

  4. MBombeck commented on Nov 27, 2026

    @MBombeck
    Owner

    @aw23edfr4 The version check from your third question is on main now (#1591), so gap 3 is closed there.

    Before the dump before migrating, the nightly dump and db-restore run pg_dump or pg_restore, they compare the server's server_version_num with the client's major. A server newer than the client is refused before anything is written, with one line that names both: "This image's PostgreSQL client (pg_dump) is 19; your server is 20", followed by the way out.

    At boot the app still won't migrate without its dump. It says why once and then waits ten minutes before it exits, so restart: unless-stopped no longer cycles it every few seconds, and docker stop ends the wait straight away. A boot with nothing to migrate starts and logs the same line as a warning. A nightly dump that fails this way shows as failing on the backups page from the first night and goes to admins as a backup alert, instead of reading as "the last dump failed".

    docs/ops/postgres-major-upgrade.md now says it plainly: the highest server major HealthLog supports is the client major in the image, 19 today, and it shows how to check both.

    It is planned for the next patch release on Saturday, 28 November, and is in the :edge image until then. The bundled move of db to 19 is still open here.

  5. MBombeck commented on Nov 28, 2026

    @MBombeck
    Owner

    @aw23edfr4 the version check is in 1.49.1, out today: https://github.com/MBombeck/HealthLog/releases/tag/v1.49.1

    If your PostgreSQL server runs a newer major than the client tools in the image, the app now names both versions and the way out instead of failing on the dump. Thanks again for tracing this one so carefully. If you can try it against your setup, I'd be glad to know it reads clearly. Refs #1431

  6. added
    bug
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions