our RAID10 failed miserably and we now have a corrupted psql database. I copied the main/ folder and now are working with a copy trying to recover data. I have progressed far enough to have made an pg_resetxlog, which at least allowed me start up the database again. I have REINDEX and have made VACUUM and set to overwrite with zeros... At this point I get the

missing chunk number 0 for toast value x 


unexpected chunk number 1 (expected 0) for toast value

using the script (taken from https://newbiedba.wordpress.com/2015/07/07/postgresql-missing-chunk-0-for-toast-value-in-pg_toast/)

for ((i=0; i<"Number_of_rows_in_nodes"; i++ )); do psql -U "Username" "Database Name" -c "SELECT * FROM nodes LIMIT 1 offset $i" >/dev/null || echo $i; done

and writing the results to a file, I get some 2000 ?lines? or ?IDs? of ?rows? that are affected. I don't know what to do from here on. I guess I have to delete the affected lines?

Thanks for the help! Bert

  • 1
    Read and act on this NOW: wiki.postgresql.org/wiki/Corruption . Though I really hope you did that before you tried to fix this, really. OK, done? Restore from backups if at all possible, that's the only truly safe course at this point. – Craig Ringer Aug 15 '17 at 1:43
  • 1
    Fixed tags; psql is for the client application. Fewer people follow it too. – Craig Ringer Aug 15 '17 at 1:43
  • If you don't have usable backups, then postgresql.org/support/professional_support might be a good choice. Or you can ask for help on the PostgreSQL IRC channel and someone might be willing to walk you through some recovery. It's not really something you can easily give canned answers for somewhere like SO, since most corruption incidents are unique. – Craig Ringer Aug 15 '17 at 1:45
  • Also, that script is a bit weird. Don't know why they didn't use a plpgsql DO block to do it much more efficiently and auto look up the primary keys too. – Craig Ringer Aug 15 '17 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.