SQLSTATE XX001 ERROR Class XX: Internal Error

data_corrupted missing chunk number N for toast value N in pg_toast_N — XX001

PostgreSQL error "missing chunk number N for toast value N in pg_toast_N" (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 could not find an expected chunk of an out-of-line TOAST value. The data is corrupt or incomplete, so it raises SQLSTATE XX001 (data_corrupted).

  • A TOAST chunk row is missing.
  • The wide value cannot be fully reassembled.
  • Classic sign of TOAST-index or heap corruption.

What the server log shows

ERROR:  missing chunk number 0 for toast value 24601 in pg_toast_16390

Why PostgreSQL raises this — what the manual says

Section 66.2.1 Out-of-Line, On-Disk TOAST Storage:

“Each chunk is stored as a separate row in the TOAST table belonging to the owning table.”

Reassembling a TOASTed value requires every chunk. A missing chunk (lost row or a corrupt TOAST index that can’t find it) makes reconstruction impossible, so PostgreSQL reports XX001.

Common causes

  • Corruption or loss of rows in the TOAST table.
  • A damaged TOAST index that cannot locate chunks.
  • Hardware faults or crashes with fsync disabled.

How to fix it

  1. REINDEX the TOAST index first — a bad index can cause this even when data is intact.
  2. If chunks are truly lost, restore from backup.
  3. Run hardware/filesystem checks and consider repairing the affected row after a backup.

Related & next steps

Reference: PostgreSQL 18 Section 73.2 “TOAST”.

Was this helpful?