Skip to content

fix(backup): check the client major against the server before dump and restore - #1591

Merged
MBombeck merged 1 commit into
mainfrom
fix/pg-client-server-major-preflight
Nov 27, 2026
Merged

MBombeck merged 1 commit into
mainfrom
fix/pg-client-server-major-preflight

Conversation

@MBombeck

Copy link
Copy Markdown
Owner

The image's pg_dump major is the highest server major HealthLog can run against, and nothing compared the two up front (Refs #1431).

  • One check in dump-core.mjs (assertClientServesServer): reads server_version_num and the tool's --version, refuses a server newer than the client with one message naming both majors and the way out. Used by createDatabaseDump (nightly dump and the dump before migrating) and db-restore. Dev and beta versions (19devel, 19beta2) read as their major; an unreadable side is not refused.
  • Boot: db-dump.mjs pre-migration exits 3 for this case. The entrypoint still refuses to migrate, says why once, and waits ten minutes (inside the healthcheck start period) before exiting, so restart: unless-stopped does not loop; docker stop ends the wait. A boot with nothing to migrate warns and starts.
  • Nightly: the stored failure is read back by the readiness model as database_dump / client_too_old, failing from the first run, so admins get it through the existing backup alert. Strings in all locales.
  • Docs: postgres-major-upgrade.md gets a section on the highest supported server major and how to check it; getting-started, unraid and truenas point at it.
  • Tests: version parsing and comparison (16/18/19/20, devel, beta, rc), db-dump exit codes, db-restore refusal, an entrypoint test that runs the script with a stand-in node, and integration cases against a real server with a client one major older.

…d restore

The image's pg_dump major is the highest server major HealthLog can run
against, and nothing compared the two before running the tool. A server
newer than the client stopped the boot at the dump before migrating with
pg_dump's own mismatch line, the container restarted into the same error
every few seconds, and the nightly dump failed the same way (#1431).

Every path that runs pg_dump or pg_restore against a server now reads
server_version_num and the tool's --version first and, when the server is
newer, refuses with one message that names both majors and the way out:
createDatabaseDump (the nightly dump and the dump before migrating) and
db-restore. The dump before migrating exits 3 for this case; the
entrypoint says why once and waits ten minutes before it exits, so a
restart policy does not loop, and docker stop ends the wait. A boot with
nothing to migrate starts and logs the same line as a warning.

The recovery readiness model reads the stored failure back and calls the
database dump failing from the first run (client_too_old), so admins get
it as a backup alert instead of "the last dump failed". The upgrade guide
and the self-hosting pages state the ceiling and how to check it.
@MBombeck
MBombeck merged commit eec4db7 into main Nov 27, 2026
42 checks passed
@MBombeck
MBombeck deleted the fix/pg-client-server-major-preflight branch December 1, 2026 09:13
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