select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS XX · INTERNAL ERROR

data_corrupted

SQLSTATE
XX001
Condition name
data_corrupted
Class
Internal Error
Source macro
ERRCODE_DATA_CORRUPTED
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>XX001</h1>

At a glance

XX001 reports an integrity invariant failure. The fixed sources cover corrupted PGLZ TOAST data, impossible MultiXact/XID freeze state in heap processing, and an amcheck B-tree check that can reveal a heap/HOT-chain problem behind an apparent index mismatch.

Meaning

The TOAST decompressor raises ERRCODE_DATA_CORRUPTED when PGLZ cannot decode the stored compressed datum. Heap freezing raises the same code when a MultiXact precedes relminmxid, remains running before the freeze cutoff, or carries an update XID before relfrozenxid or the removable cutoff. These are consistency checks on stored data and transaction metadata, not invalid user input.

The amcheck heapallindexed callback reports a heap tuple lacking its matching index tuple. Its source comments warn that an apparent index-scan problem can still be heap corruption, a bad HOT-safety decision, or another underlying fault; the optional hint only asks for a stronger verification call.

Messages

  • ERROR, SQLSTATE XX001: compressed pglz data is corrupt.
  • ERROR, SQLSTATE XX001: found multixact %u from before relminmxid %u.
  • ERROR, SQLSTATE XX001: multixact %u from before multi freeze cutoff %u found to be still running.
  • ERROR, SQLSTATE XX001: multixact %u contains update XID %u from before relfrozenxid %u.
  • ERROR, SQLSTATE XX001: multixact %u contains committed update XID %u from before removable cutoff %u.
  • ERROR, SQLSTATE XX001: heap tuple (%u,%u) from table "%s" lacks matching index tuple within index "%s".
  • When the check was entered through bt_index_check (which takes AccessShareLock and passes readonly=false to the callback), hint: Retrying verification using the function bt_index_parent_check() might provide a more specific error. The bt_index_parent_check entry point takes ShareLock, passes readonly=true, and does not append this hint. This internal verification mode is unrelated to the SQL transaction's transaction_read_only setting.

Diagnosis

Preserve the exact message and identifiers, relation/index names, block and page context, checksum and replica comparison, server log, and the first operation that observed the invariant. For TOAST, identify the owning table and compressed datum path. For heap messages, inspect relfrozenxid/relminmxid and MultiXact history without manually editing system catalogs. For amcheck, record whether the call used bt_index_check/AccessShareLock or bt_index_parent_check/ShareLock, and whether the hint was present; do not assume the index is the root cause.

Response

Treat these as integrity incidents. In an explicit transaction, an ERROR requires ROLLBACK or ROLLBACK TO an existing savepoint before more SQL, but rollback does not repair the stored object. Compare trusted backups, replicas, checksums and storage history using a read-only procedure; then restore or rebuild the affected table/TOAST data according to the incident plan. A REINDEX may be appropriate only after evidence shows corruption is index-local; it is not a generic repair for heap, TOAST, XID, or MultiXact invariants. If a separate FATAL or process termination occurred, use a new connection after recovery; do not induce corruption to test this code.

Versions

The locked catalogue records this condition from 7.4; fixed TOAST, heap, and amcheck source coverage is PostgreSQL 18.6. No corruption or crash runtime was run for this source-only page.

Sources

src/backend/access/common/toast_compression.c#L90-L100

src/backend/access/heap/heapam.c#L6983-L7042

contrib/amcheck/verify_nbtree.c#L2760-L2818

contrib/amcheck/verify_nbtree.c#L252-L305

contrib/amcheck/verify_common.c#L60-L149

The structured evidence record records the integrity message groups, conditional hint, and source/runtime boundary.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

XX001 is data_corrupted in SQLSTATE Class XX.

Method: Read locked definition snapshot.

src.errcodes.18.6

Fixed source paths cover PGLZ decompression corruption, MultiXact/XID freeze invariants, and the amcheck heapallindexed mismatch; bt_index_check uses AccessShareLock, while bt_index_parent_check uses ShareLock and causes the callback readonly flag that suppresses the parent-check hint.

Method: Read complete fixed integrity-check contexts, amcheck entry points, and the lock-mode-to-readonly mapping.

Limits: Source confirmation is not natural runtime and does not identify a particular incident root cause.

src.path.0 src.path.1 src.path.2 src.path.3 src.path.4

The locked catalogue records XX001 from 7.4; it does not prove the exact introduction rationale.

Method: Use locked catalogue boundary.

src.errcodes.18.6

Message templates

ERROR · message.0

Primary

compressed pglz data is corrupt
ERROR · message.1

Primary

found multixact %u from before relminmxid %u
ERROR · message.2

Primary

multixact %u from before multi freeze cutoff %u found to be still running
ERROR · message.3

Primary

multixact %u contains update XID %u from before relfrozenxid %u
ERROR · message.4

Primary

multixact %u contains committed update XID %u from before removable cutoff %u
ERROR · message.5

Primary

heap tuple (%u,%u) from table "%s" lacks matching index tuple within index "%s"

Hint

Retrying verification using the function bt_index_parent_check() might provide a more specific error.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:f72da1858ea8b45851822568c21… · English manual source