Diagnostic Queries
Symptoms
PostgreSQL found a relation in pg_class whose pg_attribute rows are missing or fewer than expected. The system catalogs are inconsistent, so it raises SQLSTATE XX001 (data_corrupted).
- A relation’s column metadata is incomplete.
- Indicates system-catalog corruption.
- Queries touching the relation fail.
What the server log shows
ERROR: catalog is missing 2 attribute(s) for relid 24576
Why PostgreSQL raises this — what the manual says
Section 52.7 pg_attribute:
“There will be exactly one pg_attribute row for every column in every table in the database.”
Every column of a relation must have a matching pg_attribute row. If rows are missing, the catalog cannot describe the relation’s shape — corruption — so PostgreSQL reports XX001.
Common causes
- System-catalog corruption from hardware/storage faults.
- Improper recovery or manual catalog tampering.
- Crashes with disabled fsync.
How to fix it
- Back up the current state and treat this as serious corruption.
- Restore from a known-good backup.
- Run hardware/filesystem diagnostics; never hand-edit system catalogs to “fix” it.
Related & next steps
Reference: PostgreSQL 18 Section 53.7 “pg_attribute”.
Thanks — noted. This helps keep the database accurate.