postgresqldatabase-indexes

How to fix PostgreSQL errors telling tid from new index tuple overlaps with invalid duplicate tuple?


When inserting new rows to one of my tables (having multiple indexes) from a Spring-Boot application, I sometimes get:

ERROR: table tid from new index tuple (952367,9) overlaps with invalid duplicate tuple at offset 12 of block 49008 in index "foo_index"
ERROR: table tid from new index tuple (952110,19) overlaps with invalid duplicate tuple at offset 22 of block 31693 in index "bar_index"
ERROR: table tid from new index tuple (953430,24) overlaps with invalid duplicate tuple at offset 22 of block 31693 in index "bar_index"
ERROR: table tid from new index tuple (953440,39) overlaps with invalid duplicate tuple at offset 23 of block 31693 in index "bar_index"
ERROR: table tid from new index tuple (952368,27) overlaps with invalid duplicate tuple at offset 76 of block 55849 in index "foo_index"
ERROR: table tid from new index tuple (952368,32) overlaps with invalid duplicate tuple at offset 76 of block 55849 in index "foo_index"
ERROR: table tid from new index tuple (953046,13) overlaps with invalid duplicate tuple at offset 12 of block 49008 in index "foo_index"

All these follow a warning SQL Error: 0, SQLState: XX002, which means index_corrupted according to the PostgreSQL docs.

The server version is Ubuntu 13.9-1.pgdg22.04+1.

What can I do to fix it?


Solution

  • Ran REINDEX (VERBOSE) TABLE CONCURRENTLY my_table;. It took ~30 minutes. (The table has ~30M rows.) So far, the errors did not reappear.