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!
-
Seems like a corrupted index. Is there anything related in the Postgres logfile?ypercubeᵀᴹ– ypercubeᵀᴹ2016年04月20日 07:25:37 +00:00Commented Apr 20, 2016 at 7:25
-
Also, which exact version do you run?ypercubeᵀᴹ– ypercubeᵀᴹ2016年04月20日 07:27:00 +00:00Commented Apr 20, 2016 at 7:27
1 Answer 1
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
-
Fair enough. Although, shouldn't I just run
reindex index links_grouptraffic_time
, since that's the index the error relates to?Hassan Baig– Hassan Baig2016年04月20日 07:30:19 +00:00Commented Apr 20, 2016 at 7:30 -
That is the error that you "stumbled upon" so far. If you used your database and ran out of space, you'll likely have similar errors in any indexes of tables updated while out of space.Ezequiel Tolnay– Ezequiel Tolnay2016年04月20日 07:32:07 +00:00Commented Apr 20, 2016 at 7:32
-
I had the same error on postgres 9.6 and used these steps: reindex system <dbname>; reindex database <dbname>; vacuum (full) <dbname>;Gudmundur Orn– Gudmundur Orn2019年04月01日 11:27:55 +00:00Commented Apr 1, 2019 at 11:27
-
In My case I am not able to start database. So Can I reindex?Sanjay– Sanjay2020年10月14日 04:06:42 +00:00Commented Oct 14, 2020 at 4:06
-
1@Sanjay it depends on the kind and extent of damage to your database. In order to recover information from a corrupted database, you will require some basic understanding of what are the files in a postgresql system's PGDATA folder (e.g. /var/lib/postgresql/xx/main). Your database is in
base
. You may be able to recover your database by saving a copy of your PGDATA folder, then reinitialise your repository (i.e.initdb
), start it, create a new empty database in (e.g.CREATE DATABASE recovered
), stop the service, replace the contents of that new database with your old database, then start.Ezequiel Tolnay– Ezequiel Tolnay2020年10月17日 05:35:58 +00:00Commented Oct 17, 2020 at 5:35