![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, On running pg_dump, I am consistently getting the following errors: pg_dump: ERROR: unexpected chunk number 2 (expected 0) for toast value 223327 pg_dump: SQL command to dump the contents of table "pagecache" failed: PQendcopy() failed. pg_dump: Error message from server: ERROR: unexpected chunk number 2 (expected 0) for toast value 223327 pg_dump: The command was: COPY meatballwiki.pagecache (page, lastmodified, response) TO stdout; I am running psql 8.1.4. The disk storing the database was recently corrupted, and we restored from an old image; I appreciate this is likely to have triggered the error. What I'm interested in is how to fix it! |
#3
| |||
| |||
|
|
"old image" - does that refer to something like an filesystem level backup or the restoration of a former pg_dump generated backup ? The former is generally NOT save (except if you followed the PITR- advises in the docs or similiar) with a running postmaster ... |
#4
| |||
| |||
|
|
Given that we are where we are, what is the best advice? Can we recover the database, given that 99% of the data works? I can happily drop the entire contents of the "pagecache" table, as it is regenerated on the fly, if that will obviate the problem. |
#5
| |||
| |||
|
|
That will get you past the reported problem, but I wonder what other corruption is lurking ... once you've managed to pg_dump you'd better inspect the data very carefully. |
#6
| |||
| |||
|
|
That will get you past the reported problem, but I wonder what other corruption is lurking ... once you've managed to pg_dump you'd better inspect the data very carefully. Would the best advice be to get a pg_dump, then drop the database entirely and rebuild it? |
#7
| |||
| |||
|
|
Would the best advice be to get a pg_dump, then drop the database entirely and rebuild it? Definitely. It's entirely possible for pg_dump to dump successfully from a database that still contains corruption. An example: broken indexes on user tables. COPY just does a seqscan and never looks at the contents of indexes ... |
#8
| |||
| |||
|
|
Would the best advice be to get a pg_dump, then drop the database entirely and rebuild it? Definitely. It's entirely possible for pg_dump to dump successfully from a database that still contains corruption. An example: broken indexes on user tables. COPY just does a seqscan and never looks at the contents of indexes ... Just out of curiosity, why is it not possible to rebuild these indices entirely from scratch, dropping the defective file entirely, *without* reimporting into a fresh database? |
#9
| |||
| |||
|
|
See REINDEX. But my point was that there may be undetected corruption. If I were you I'd not rely on REINDEX to prevent all problems. |
![]() |
| Thread Tools | |
| Display Modes | |
| |