An in-place major version upgrade on RDS for PostgreSQL either completes or rolls back to the old version with a terse event such as "Database instance is in a state that cannot be upgraded". The instance usually comes back on the old version, but you have spent your maintenance window. Most failures come from a short list of blockers that pg_upgrade checks for. You can find all of them in advance.
This checklist covers in-place upgrades with modify-db-instance. For a one-minute switchover with a tested copy, see the blue/green deployment checklist instead.
Before the window: target version and dependencies
1. Confirm the upgrade path exists
Not every major version can jump straight to every later one. Ask RDS for the valid targets from your exact current version:
aws rds describe-db-engine-versions \
--engine postgres --engine-version 13.15 \
--query "DBEngineVersions[].ValidUpgradeTarget[?IsMajorVersionUpgrade==\`true\`].EngineVersion" \
--output text
If your target is not listed, upgrade to an intermediate minor or major version first.
2. Check the instance class is supported on the target
Older classes (for example some db.m4/db.t2 sizes) are not offered on newer engine versions:
aws rds describe-orderable-db-instance-options \
--engine postgres --engine-version 16.4 \
--db-instance-class db.r6g.large \
--query "OrderableDBInstanceOptions[0].DBInstanceClass"
An empty result means you need to change the class first, in a separate change.
3. Prepare a parameter group for the new family
Custom parameter groups are tied to a family (postgres13, postgres16, and so on). Create the new one ahead of time and copy across the settings you changed:
aws rds create-db-parameter-group \
--db-parameter-group-name app-pg16 \
--db-parameter-group-family postgres16 \
--description "App settings for PostgreSQL 16"
aws rds describe-db-parameters --db-parameter-group-name app-pg13 \
--source user --query "Parameters[].[ParameterName,ParameterValue]" --output table
Some parameters are renamed or removed between major versions. Check each one against the new family before you apply it.
Database-level blockers
Connect to every database on the instance, not only the application database. The precheck runs against all of them, including ones nobody remembers creating.
SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate;
4. Logical replication slots
The upgrade fails if logical replication slots exist. Find them, confirm who owns them (DMS tasks, Debezium, logical subscribers), and drop them only after that consumer is stopped:
SELECT slot_name, slot_type, database, active, plugin
FROM pg_replication_slots;
SELECT pg_drop_replication_slot('dms_slot_example');
Warning
Dropping a slot breaks the CDC pipeline that uses it. After the upgrade, the consumer usually needs a full reload or a new start position. Agree this with the pipeline owner before the window.
5. Open prepared transactions
SELECT gid, prepared, owner, database FROM pg_prepared_xacts;
Any row blocks the upgrade. Find out which application created it. If it is safe, finish it with COMMIT PREPARED 'gid'; or discard it with ROLLBACK PREPARED 'gid';.
6. Unsupported reg* data types in user tables
pg_upgrade cannot carry over columns that store OIDs as regproc, regprocedure, regoper, regoperator, regconfig, regdictionary or regnamespace. regclass, regrole and regtype are fine. Find them:
SELECT n.nspname, c.relname, a.attname, a.atttypid::regtype AS type
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
WHERE NOT a.attisdropped
AND c.relkind IN ('r', 'm')
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
AND a.atttypid IN ('pg_catalog.regproc'::regtype, 'pg_catalog.regprocedure'::regtype,
'pg_catalog.regoper'::regtype, 'pg_catalog.regoperator'::regtype,
'pg_catalog.regconfig'::regtype, 'pg_catalog.regdictionary'::regtype,
'pg_catalog.regnamespace'::regtype);
Convert those columns to text or drop them before you upgrade. On PostgreSQL 13 and later, add regcollation to the list too. The exact list of types depends on the source and target versions, so check the pg_upgrade documentation for your pair.
7. Extensions, especially PostGIS
Outdated extensions are the most common cause of failed upgrades. List what is installed and what version is available:
SELECT name, installed_version, default_version
FROM pg_available_extensions
WHERE installed_version IS NOT NULL
ORDER BY name;
Update anything where installed_version is behind default_version, in every database:
ALTER EXTENSION pg_stat_statements UPDATE;
-- PostGIS and its dependent extensions:
SELECT postgis_full_version();
SELECT postgis_extensions_upgrade();
Also check that each extension exists on the target engine version. Look up the RDS "supported extensions" list for your target. Drop extensions that are not on it and that you no longer use.
8. Size the object count
pg_upgrade time depends on the number of objects more than on data size. Very large catalogs make the outage longer:
SELECT count(*) AS relations FROM pg_class;
SELECT count(*) AS large_objects FROM pg_largeobject_metadata;
Millions of large objects or tables can stretch the downtime well past what you would expect. Rehearse on a restored snapshot to get a real number.
Tip
AWS publishes an open-source major version upgrade precheck script on GitHub that runs these checks against every database at once. Run it against a snapshot restore as a second opinion.
Running the upgrade
9. Take your own snapshot and rehearse
When backups are enabled, RDS takes snapshots as part of the upgrade. Take a manual one anyway so that you control the name and retention:
aws rds create-db-snapshot \
--db-instance-identifier app-db \
--db-snapshot-identifier app-db-pre-pg16-2026-11-27
Restore it to a temporary instance and run the exact same upgrade command there first.
10. Apply the upgrade
aws rds modify-db-instance \
--db-instance-identifier app-db \
--engine-version 16.4 \
--allow-major-version-upgrade \
--db-parameter-group-name app-pg16 \
--apply-immediately
If you use an option group, pass a matching --option-group-name too. Read replicas are affected by a major upgrade, and the behaviour differs between same-Region and cross-Region replicas. Check the current RDS documentation for your replica layout before the window.
Follow the progress:
aws rds describe-events --source-type db-instance \
--source-identifier app-db --duration 120 \
--query "Events[].[Date,Message]" --output text
When it fails: read the logs
The event tells you that the upgrade failed. The log file tells you why. RDS writes pg_upgrade_precheck.log (or pg_upgrade_server.log / pg_upgrade_internal.log for later stages) with a timestamp in the name:
aws rds describe-db-log-files --db-instance-identifier app-db \
--filename-contains pg_upgrade --query "DescribeDBLogFiles[].LogFileName" --output text
aws rds download-db-log-file-portion --db-instance-identifier app-db \
--log-file-name "error/pg_upgrade_precheck.log.2026-11-27-02-10" \
--starting-token 0 --output text > precheck.log
File names vary by version, so copy the exact name from the first command's output.
| Log message (abridged) | Cause | Fix |
|---|---|---|
logical replication slots / slot exists | Slots from DMS or CDC tools | Stop the consumer, drop the slot (item 4) |
prepared transactions | Rows in pg_prepared_xacts | Commit or roll back (item 5) |
reg* data types in user tables | OID-referencing columns | Convert or drop (item 6) |
| Extension version or "could not load library" | Old PostGIS or another old extension | ALTER EXTENSION ... UPDATE in every database (item 7) |
incompatible ... parameter / instance in incompatible-parameters | Parameter group from the wrong family or a bad value | Fix the postgresNN group and retry |
| Upgrade path not supported | Target not in ValidUpgradeTarget | Use an intermediate version (item 1) |
After the upgrade
11. Refresh statistics
The optimizer needs fresh statistics, and plans are poor until you have them. Run this in each database:
ANALYZE VERBOSE;
Newer pg_upgrade releases can carry statistics over. Check your target version's release notes, and run ANALYZE anyway if in doubt.
12. Update extensions again and rebuild CDC
Some extensions need ALTER EXTENSION ... UPDATE on the new version as well. Recreate the logical slots and restart the CDC consumers that you stopped in item 4.
13. Verify
SELECT version();
SELECT name, setting FROM pg_settings WHERE source NOT IN ('default', 'override');
Compare the second query against the settings you captured in item 3.
Prevent it next time
- Add the queries for items 4 to 7 to a scheduled job and alert when they return rows, so blockers are visible months before an upgrade.
- Keep one parameter group per major family in infrastructure as code. Then the new family is a diff, not something you rebuild by hand during the window.
- Rehearse every major upgrade on a snapshot restore and record the downtime. Use that number when you schedule the change.
- Track the end of standard support for your engine versions so you plan the upgrade. Otherwise RDS forces it, or you pay for extended support.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get