PostgreSQL 9.3 – Error: Failed to Re-find Parent Key in Index

indexpostgresqlpostgresql-9.3

I have a Django app with a postgresql 9.3 DB (hosted on Ubuntu VM), and very recently the VM ran out of disk space (resulting in no space left on device errors showing up in my logs).

I cleared the space on the device and everything came back online.

But now, for a minority of my requests, I've started receiving a django.db.utils:DatabaseError alert, with the description failed to re-find parent key in index "links_grouptraffic_time" for split pages 24582/24583. links_grouptraffic is one of my data models, and time is an attribute within that data model.

Can someone explain the background of what this means, and a remedy for this problem? Thanks in advance!


Best Answer

Your database is likely corrupted, especially the indexes. You can rebuild all indexes and check all tables on a database by:

REINDEX SYSTEM; -- run once
REINDEX DATABASE <your dbname>; -- run for each database
VACUUM (FULL VERBOSE ANALYZE); -- also run for each database after reindexing