SQLSTATE XX001 PANIC Class XX: Internal Error

data_corrupted Data Corrupted — SQLSTATE XX001

PostgreSQL detected corrupted data on disk.

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

Symptoms

PostgreSQL detected corrupted data on disk.

  • The error is written to the server log and returned to the client carrying SQLSTATE XX001.
  • Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.

Environment

Severity: PANIC  |  PostgreSQL versions: 12, 13, 14, 15, 16, 17

Indicates a system- or storage-level problem; inspect OS logs, disk health, and any recent hardware or filesystem changes.

Root Cause

A page failed verification (checksum or structural check) — the stored data is damaged.

Common causes:

  • A bad disk or memory (non-ECC).
  • Power loss without proper fsync.
  • Filesystem or storage misconfiguration.

Diagnostic Queries

Recovery

Steps to resolve XX001:

  1. Stop writing to the affected system and take a physical copy before any repair.
  2. Restore from a verified backup — this is the safe path.
  3. As a last resort, zero_damaged_pages can read past damage but discards corrupt pages and risks data loss; use only with guidance and a backup.
  4. Enable data checksums and ECC memory to catch problems earlier.

Reference: PostgreSQL error codes — Class XX (Internal Error).

Was this helpful?