My Ubuntu 14.04 LTS server running postgresql 8.4.11 crashed, and after a reboot the application server running a query against postgresql reported the following error
ERROR: invalid page header in block 40 of relation base/18038/22194 I googled, tried to create a dump, and used the resulting error message to identify a broken table. I then executed
SET zero_damaged_pages = on; VACUUM FULL damaged_table; -- vacuum didn't report any errors here REINDEX TABLE damaged_table; others mentioned reindexdb, so I ran
$ reindexdb -s mydb as well, but the problem still stayed the same.
Finally - I got a working backup from the database - I dropped and recreated the whole database
DROP DATABASE mydb; CREATE DATABASE mydb; and restored the backup:
cat mydump| sudo -u postgres pgsql mydb But even now the problem is still the same. I don't know much about postgresql, but how can such an error survive a recreation of the database? Unfortunately I need to get the database working on the same machine again.
Is there anything else I can try to get the database working again?