PostgreSQL will not start: invalid resource manager ID in primary checkpoint record
invalid resource manager ID in primary checkpoint recordShort 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.
Fix it fast
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 402Match what you see, then jump to its fix
- 1
The 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
The 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
- 1
What does the error look like?
invalid resource manager ID in primary checkpoint recordPostgreSQL 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=03Verify
After restoring and scaling back up, the log shows normal recovery and the pod becomes ready.
kubectl logs <postgres-pod> | tail -n 20Confirmed by postgresql.org
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,pvc2Fix
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/data3Verify
The server starts, and pg_dumpall completes without errors.
pg_dumpall -U postgres > all-databases.sqlConfirmed by postgresql.org
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
Databases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fixDatabases
Django migration on PostgreSQL stops with 'pending trigger events'
django.db.utils.OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events
PostgreSQL runs a Django migration in one transaction.
2 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fix