User Tools

Site Tools


how_to:repairing_corrupted_database

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
how_to:repairing_corrupted_database [2015/01/13 08:58] – [Finding the problem message] paulhow_to:repairing_corrupted_database [2016/02/05 11:24] – [Delete the problem message] 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, but there are no guarantees we will be able to recover anything.+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.
  
 Before you start you should: Before you start you should:
Line 31: Line 31:
 The only solution we know of is to delete the relevant record (message) totally. The only solution we know of is to delete the relevant record (message) totally.
  
-Unfortunately, there is no easy way to find which record is damaged, so you need to use a 'divide & conquer' approach+Unfortunately, there is no easy way to find which record is damaged, so you need to scan the entire table
  
 Go to a command prompt in the VPOP3 directory and run 'psql' (in version 5 only). The default password is 'vpop3pass' Go to a command prompt in the VPOP3 directory and run 'psql' (in version 5 only). The default password is 'vpop3pass'
Line 39: Line 39:
 Copy/paste the following into the psql prompt: Copy/paste the following into the psql prompt:
  
-[code]+<code>
 DO $f$ DO $f$
 declare declare
Line 64: Line 64:
 end; end;
 $f$; $f$;
-[/code]+</code>
  
 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
Line 86: Line 86:
 This will delete the message from the database, so it should now work OK, but without the message you have just deleted. This will delete the message from the database, so it should now work OK, but without the message you have just deleted.
  
 +In some cases you may need to disable database triggers before doing this. To do this, stop VPOP3 first, then, before doing the DELETE commands do:
 +
 +  ALTER TABLE messages.foldermessages DISABLE TRIGGER USER;
 +
 +After doing the deletions, re-enable the triggers by doing:
 +
 +  ALTER TABLE messages.foldermessages ENABLE TRIGGER USER;
 +  
 +Failure to re-enable the triggers will cause big problems for VPOP3!
 +  
 +In rare cases the database files may be even more corrupted, so you need to run this command before deleting the records:
 +
 +  SET zero_damaged_pages=on;
 +  
 +This should be considered a 'last resort' option - http://www.postgresql.org/docs/9.1/static/runtime-config-developer.html#GUC-ZERO-DAMAGED-PAGES
 ====Rebuild database==== ====Rebuild database====
-After you have done this, we strongly recommend doing a full [[backup_vpop3#manual_database_backup|backup]]/[[restore_a_backup_of_vpop3|restore]] of the database in case there is any other damage to the database files.+After you have done this, we strongly recommend doing a full [[backup_vpop3#manual_database_backup|backup]]/[[restore_a_backup_of_vpop3|restore]] of the database as there will be  other problems which will cause problems at a later date, such as the automatic clean-up processes (meaning the database size will increase uncontrollably).
 ====Also See==== ====Also See====
 [[PostgreSQL Server won't start due to damaged log files]] [[PostgreSQL Server won't start due to damaged log files]]
how_to/repairing_corrupted_database.txt · Last modified: 2024/01/15 11:35 by paul