Skip to main content
RunBook Academy

PostgreSQLXVII · Capacity, Maintenance and UpgradesMaintenance

Minor version upgrades

Foundation⏱ ~25 minpsql

What you'll learn

  • Perform a minor version upgrade with the correct sequence
  • Explain why it needs no data migration
  • Read the release notes for the exception that needs action
  • Order a replicated estate correctly

Prerequisites

Verified against PostgreSQL 18.x · PostgreSQL (comparison targets) 17.11, 16.15 · PostgreSQL (support calendar) 18, 17, 16, 15, 14 supported · pgBackRest 2.59.1 · PgBouncer 1.25.2 · Patroni 4.1.5 · Ubuntu (host baseline) 26.04 LTS · 2026-08-27

Not yet marked complete on this device.

Minor upgrades — 18.5 to 18.6 — are the cheapest maintenance PostgreSQL offers and the most frequently deferred.

What a minor release is

The version is major.minor: in 18.6, 18 is the major version and 6 is the minor. Minor releases contain security fixes, bug fixes and data-corruption fixes. They contain no new features and no on-disk format changes.

That last part is the whole reason the procedure is short: the data directory written by 18.5 is the data directory 18.6 reads. There is nothing to convert.

The procedure

# 1. Read the release notes for every version you are skipping.
#    This is the step that is skipped and the one that matters.

# 2. Stop the cluster cleanly.
pg_ctl -D $PGDATA stop -m fast

# 3. Replace the binaries (package manager).
apt-get install --only-upgrade postgresql-18

# 4. Start.
pg_ctl -D $PGDATA start

# 5. Verify.
psql -c "SELECT version();"

Downtime is a fast shutdown plus a startup — lesson XII-07 measured a fast shutdown at 119 ms on a small cluster, and startup is dominated by whatever crash recovery is needed, which after a clean shutdown is none.

Why they get deferred, and why that is a mistake

The reasons are always the same: it needs a restart, nothing is obviously broken, and there is no new feature to want.

Against that:

  • Minor releases contain security fixes, published with the release. Not applying them is a decision to run known-vulnerable software.
  • They contain data-corruption fixes. Some of the most serious PostgreSQL bugs have been silent corruption fixed in a minor release.
  • The community supports only the latest minor version. A bug report against 18.2 is answered with “upgrade to the current minor first”.
  • They accumulate. Six deferred minor upgrades is not six times the risk of one; it is one upgrade with six releases of changes in it and correspondingly more release notes nobody read.

Verifying

SELECT version();
SELECT count(*) FROM pg_stat_replication;   -- on the primary
SELECT pg_is_in_recovery();                 -- on each standby

And check the log for anything unexpected on startup. A minor upgrade that went wrong usually says so immediately — a missing library, a version mismatch between the binaries and the data directory — rather than failing subtly later.

What to take from this

  • Minor releases change no on-disk format. Stop, swap binaries, start.
  • Downtime is a shutdown plus a startup.
  • Standbys first, primary last. A newer standby is supported; a newer primary is not.
  • Minor releases carry security and data-corruption fixes, and only the latest minor version is supported.
  • Read the “Migration to Version X.Y” section for every version you skip. Occasionally a fix requires a REINDEX you must do yourself.
  • Verify with SELECT version() — it reports the running server, and a cluster that was not restarted is still on the old one.

Cross-course references

  • Linux for Production Sysadmins — Part XI (Package management), Part XXXII (Vulnerability and patch management) and Part XXXIII (Fleet patch management) cover the patching cadence this fits into, including the restart that a package update does not perform.
  • Ansible for Production Sysadmins — Part XL (Patch and reboot management) and Part XXXI (Serial execution) cover upgrading an estate one node at a time, standbys first.

Quiz

Knowledge check · 6 questions

  1. Q1. Why does a minor version upgrade need no data migration?

  2. Q2. In what order should a primary and its standbys be upgraded to a new minor version?

  3. Q3. A minor upgrade was applied a week ago, but SELECT version() still reports the old version. What happened?

  4. Q4. Which are genuine reasons not to defer minor upgrades? Select all that apply.

  5. Q5. Installing a minor release that fixes an index-corruption bug also repairs indexes already corrupted by it.

  6. Q6. What can go wrong around a minor upgrade, given that the database itself needs no data change?

Passing score: 75%. Answers are checked in this browser.