Investigation
Symptoms
A statement failed with SQLSTATE XX002 (index_corrupted), reported at severity ERROR. This is a Internal Error condition: PostgreSQL emits the message right sibling's left-link doesn't match: block n links to n instead of expected n in index "…".
- The client receives SQLSTATE
XX002(index corrupted). - The operation is rejected at
ERRORlevel; the statement does not complete.
What the server log shows
ERROR: right sibling's left-link doesn't match: block n links to n instead of expected n in index "…"
Why PostgreSQL raises this
Class XX (Internal Error) indicates a condition that should not normally occur — often a sign of data corruption or a server bug. These warrant careful investigation.
As described in PostgreSQL’s Chapter 30 Reliability and the Write-Ahead Log and Appendix A (PostgreSQL Error Codes), SQLSTATE XX002 carries the condition name index_corrupted in class Internal Error. (Paraphrased — see the linked reference for the exact wording.)
Common causes
- Data or index corruption (often storage/hardware related).
- An unexpected internal state or a server bug.
- A failed consistency check during execution.
How to fix it
- Capture the full message, context, and server version.
- Check storage/hardware and recent crash history.
- Take a backup and consider reporting a reproducible case upstream.
Version applicability
This message is present in PostgreSQL 15, 16, 17, 18 and 19.
Related & next steps
Reference: PostgreSQL Chapter 30 Reliability and the Write-Ahead Log.
Related & next steps
Concepts on this page
Thanks — noted. This helps keep the database accurate.