XX001: data_corrupted
PostgreSQLWhat does it mean?
PostgreSQL detected data corruption in a table/heap page. The query cannot complete safely because the content of the block read is inconsistent ('invalid page in block').
Why does it happen?
Disk/storage failure, file system corruption, fsync guarantees not being honored during a sudden power loss, faulty hardware (RAM/controller) or, rarely, a software bug. With checksums enabled, corruption is caught earlier.
How to fix it
First verify the hardware/storage and, if possible, plan to fall back to a physical backup (PITR) immediately. If a good backup exists, restore it. For recovery, AT THE RISK OF DATA and only as a last resort, you can zero out damaged pages with zero_damaged_pages = on and export the readable data (this causes data loss). Enable data_checksums (on an existing cluster with PG12+, pg_checksums --enable while the server is stopped), run RAM tests and take regular PITR backups.