index “…” contains unexpected zero page at block N
Symptoms
PostgreSQL found an all-zero page where a valid index page was expected. The index is corrupt and PostgreSQL raises SQLSTATE XX002 (index_corrupted).
- An index block is unexpectedly all zeros.
- A HINT suggests the index may need to be REINDEXed.
- Index scans on the affected index fail.
What the server log shows
ERROR: index "orders_pkey" contains unexpected zero page at block 42
HINT: Please REINDEX it.
Why PostgreSQL raises this — what the manual says
As the REINDEX reference (Description) explains:
An index access found an all-zero page where a valid index page was expected — a sign of index corruption (often from hardware faults or an unclean shutdown); rebuilding the index with REINDEX recreates its pages from the table data.
Index pages must be valid; an all-zero page indicates the index is damaged (e.g. an interrupted write or storage fault). Because the index can no longer be trusted, scans fail with XX002 until it is rebuilt.
Common causes
- A crash or storage fault during an index write.
- Underlying disk/filesystem corruption.
- An interrupted operation that left the index inconsistent.
How to fix it
- Rebuild the index:
REINDEX INDEX orders_pkey;(orREINDEX TABLE). - Use
REINDEX INDEX CONCURRENTLYto avoid locking writes (PG12+). - Investigate the underlying storage if corruption recurs.
Related & next steps
Reference: PostgreSQL 18 — REINDEX.