Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

PostgreSQL will not start: invalid resource manager ID in primary checkpoint record

Errorinvalid resource manager ID in primary checkpoint record

Short answer

This error means the write-ahead log at the last checkpoint is unreadable, so the server cannot recover. It follows a data directory copied while the server ran, or a crash on storage that lost writes. Restore a good backup if you have one. Only as a last resort run pg_resetwal, then dump and rebuild.

  • Applies to PostgreSQL 16, PostgreSQL 17, Kubernetes 1.31
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the start-up log of the failing instance from the top. It shows what Postgres was doing before the error, such as recovering after an unclean stop. Do not delete anything yet, and take a copy of the data volume first.

    kubectl logs <postgres-pod> --previous | head -n 40
  2. 2Match what you see, then jump to its fix

    1. 1The failure began right after restoring a volume, cloning a PVC, or copying files with tar or cp.The data directory was copied or snapshotted while the server was runningFix
    2. 2The pod was killed or the node lost power, no backup is available, and the error appears at every start.A crash left a damaged WAL because the storage lost writesFix

What does the error look like?

  • invalid resource manager ID in primary checkpoint record
  • PostgreSQL container restarts in a loop and never reaches ready

Cause 1 of 2

The data directory was copied or snapshotted while the server was running

1Check

The PostgreSQL manual says a file-system backup is only usable if the server was shut down, or if the snapshot was a consistent one that includes the WAL files. Copying a live directory file by file does not give a consistent state.

kubectl describe pvc <claim-name>

2Fix

Restore from a proper backup instead: a copy taken with the server stopped, a consistent snapshot that includes the WAL, or a logical dump. Stop the server before restoring files.

# scale the database down before replacing files on the volume
kubectl scale statefulset <postgres-statefulset> --replicas=0

3Verify

After restoring and scaling back up, the log shows normal recovery and the pod becomes ready.

kubectl logs <postgres-pod> | tail -n 20

Confirmed by postgresql.org

Did this fix it?

Cause 2 of 2

A crash left a damaged WAL because the storage lost writes

1Check

WAL records carry a CRC-32C check, so damage is detected. The manual warns that disks and SSDs with volatile write caches can lose data in a power failure, and that the administrator must make sure the storage honours flushes.

kubectl get pv,pvc

2Fix

Last resort, from the manual: stop the server, make a full copy of the data directory, preview with --dry-run, then run pg_resetwal with -f as the user that owns the data directory. Start the server, dump everything immediately and restore into a freshly initialised cluster. Make no data changes before the dump.

# inside a one-off container that mounts the same data volume, as the postgres user
pg_resetwal -n -D /var/lib/postgresql/data
pg_resetwal -f -D /var/lib/postgresql/data

3Verify

The server starts, and pg_dumpall completes without errors.

pg_dumpall -U postgres > all-databases.sql

Confirmed by postgresql.org

Did this fix it?

How do I stop it coming back?

  • Take backups with a method the manual supports, and test a restore on a spare volume.
  • Use storage that honours flush commands; check the storage class of your cluster and its provider's notes.
  • Keep regular logical dumps, so recovery never depends on pg_resetwal.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.