XX002: index_corrupted
PostgreSQLWhat does it mean?
Corruption was detected in an index structure. Because the data the index points to is inconsistent with the actual rows in the heap, queries using the index can return wrong results or fail.
Why does it happen?
Hardware/storage failure, B-tree ordering broken by a collation (sort rule) change after an operating system glibc/ICU upgrade, or a sudden outage. Operating system collation updates in particular cause silent corruption in text indexes.
How to fix it
Rebuild the corrupted index: REINDEX INDEX idx_name; or REINDEX TABLE my_table; On large tables use REINDEX INDEX CONCURRENTLY to reduce locking. If collation is the cause, rebuild all affected text indexes and verify them with the amcheck extension (bt_index_check). If the root cause is hardware, replace the storage.