SQLSTATE XX001 ERROR Class XX: Internal Error

data_corrupted invalid page in block N of relation … — XX001

PostgreSQL error "invalid page in block N of relation …" (SQLSTATE XX001): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

PostgreSQL read a data block whose page header failed validation — the page contents are not a valid PostgreSQL page. This indicates data corruption and raises SQLSTATE XX001 (data_corrupted).

  • The page header/checksum did not validate.
  • A strong signal of on-disk corruption.
  • Queries touching the affected block fail.

What the server log shows

ERROR:  invalid page in block 1234 of relation base/16384/24576

Why PostgreSQL raises this — what the manual says

Section 30.2 Data Checksums:

“Data pages are checksummed by default, and full page images recorded in WAL records are always checksum protected.”

Before using a page, PostgreSQL validates its header (and checksum if enabled). A page that fails this check is treated as corrupt and the read is aborted with XX001 to avoid acting on bad data.

Common causes

  • Storage/hardware faults writing or returning bad blocks.
  • OS or filesystem corruption.
  • A crash with disabled fsync or unsafe write caches.

How to fix it

  1. Back up the data directory immediately; do not write more to the cluster.
  2. Investigate hardware/filesystem; enable data checksums on future clusters.
  3. Restore from backup/PITR; as a last resort, advanced recovery with zero_damaged_pages (data loss) under expert guidance.

Related & next steps

Reference: PostgreSQL 18 Section 30.2 “Reliability”.

Was this helpful?