This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
how_to:repairing_corrupted_database [2016/04/06 11:15] – paul | how_to:repairing_corrupted_database [2024/01/15 11:35] (current) – paul | ||
---|---|---|---|
Line 9: | Line 9: | ||
If that is not possible, then in some cases, you may be able to remove the damaged parts of the database and recover from there while keeping most of the important data intact. This article explains some possible ways to do this. Note that none of these methods are guaranteed, and are done at your own risk. | If that is not possible, then in some cases, you may be able to remove the damaged parts of the database and recover from there while keeping most of the important data intact. This article explains some possible ways to do this. Note that none of these methods are guaranteed, and are done at your own risk. | ||
- | We can help you with these under our chargeable service which costs £30/hr (or part of) for this type of problem, but there are no guarantees we will be able to recover anything. | + | We can help you with these under our chargeable service which costs £40/hr (or part of) for this type of problem, but there are no guarantees we will be able to recover anything. |
Before you start you should: | Before you start you should: | ||
Line 32: | Line 32: | ||
Then type (or copy/paste) | Then type (or copy/paste) | ||
- | select n.nspname AS schema, c.relname AS tablename, c.reltype | + | select n.nspname AS schema, c.relname AS tablename, c.relkind |
| | ||
In the above example error message < | In the above example error message < | ||
- | If 'type' is ' | + | If 'kind' is ' |
+ | |||
+ | If the problem is in a normal table, then depending on the table name, you may be able to delete the table without losing critical data. Please contact support@pscs.co.uk with the table name and we will be able to tell you what is stored in that table, and how to delete it if that is an appropriate action. | ||
=====unexpected chunk number===== | =====unexpected chunk number===== | ||
Line 50: | Line 52: | ||
Unfortunately, | Unfortunately, | ||
- | Go to a command prompt in the VPOP3 directory and run ' | + | Go to a command prompt in the VPOP3\pgsql\bin |
====Finding the problem message==== | ====Finding the problem message==== | ||
Line 63: | Line 65: | ||
badid INT; | badid INT; | ||
begin | begin | ||
+ | DROP TABLE IF EXISTS badids; | ||
+ | CREATE TEMP TABLE badids (msgdataid BIGINT); | ||
FOR badid IN SELECT msgdataid FROM messages.msgdata ORDER BY msgdataid LOOP | FOR badid IN SELECT msgdataid FROM messages.msgdata ORDER BY msgdataid LOOP | ||
curid = curid + 1; | curid = curid + 1; | ||
Line 75: | Line 79: | ||
exception | exception | ||
when others then | when others then | ||
+ | INSERT INTO badids (msgdataid) VALUES(badid); | ||
raise notice 'data for message % is corrupt', | raise notice 'data for message % is corrupt', | ||
continue; | continue; | ||
Line 84: | Line 89: | ||
This will read all the messages from the database, and tell you which message(s) it encountered an error with | This will read all the messages from the database, and tell you which message(s) it encountered an error with | ||
+ | |||
+ | However, sometimes it won't find all problem messages, so it is a good idea to run it again after fixing any problems, until this script doesn' | ||
+ | |||
+ | This script stores the bad message IDs in a temporary table called ' | ||
===Getting message summary info=== | ===Getting message summary info=== | ||
Line 90: | Line 99: | ||
SELECT subject, messagetime, | SELECT subject, messagetime, | ||
and | and | ||
- | SELECT username, folder FROM messages.foldermessages INNER JOIN users.users ON messages.foldermessages.userid=users.users.username | + | SELECT username, folder FROM messages.foldermessages |
this will tell you summary information about the message which may help know which message will been deleted | this will tell you summary information about the message which may help know which message will been deleted |