SQL error checking
SQL error checking
For the built-in MySQL server, have the server automatically repair database errors that it encounters.
To me, it seems silly to have the server completely hang because the greylisting table (or any other non-essential table) is corrupt.
I propose that if Hmailserver detects a database error, it stops itself (if it's a table that is absolutely required to run) and repairs the table, or disables the feature (greylisting in our current case) repairs the table, then re-enables the feature.
To me, it seems silly to have the server completely hang because the greylisting table (or any other non-essential table) is corrupt.
I propose that if Hmailserver detects a database error, it stops itself (if it's a table that is absolutely required to run) and repairs the table, or disables the feature (greylisting in our current case) repairs the table, then re-enables the feature.
hMailServer 4.4.2 B281 with external MSSQL 2005
Win 2003 SP1
IIS 6
PHP 4.4.2
SquirrelMail 1.4.8
SpamAssassin 3.2.4 and ClamAV .92 on Backend Ubuntu systems
Win 2003 SP1
IIS 6
PHP 4.4.2
SquirrelMail 1.4.8
SpamAssassin 3.2.4 and ClamAV .92 on Backend Ubuntu systems
I think I have two different opinions on this. My developer perspective opinion is that this would be very "ugly" feature in terms of "problem ownership" etc. Also have a more pragmatic opinion where I see that this may be needed.
If you add the following line to \hMailServer\MySQL\my.ini, MySQL will check whether the file is corrupt. If so, it will repair it and backup the current file.
I have never had a problem with MySQL corruption myself, so it's a bit hard to test in a good way. I did however test this by corrupting one of the database files (by editing it in notepad). After adding the row below and restarted MySQL, MySQL automatically repaired the table.
myisam-recover=FORCE,BACKUP
I'm not sure what effect this has on MySQL performance though.
If you add the following line to \hMailServer\MySQL\my.ini, MySQL will check whether the file is corrupt. If so, it will repair it and backup the current file.
I have never had a problem with MySQL corruption myself, so it's a bit hard to test in a good way. I did however test this by corrupting one of the database files (by editing it in notepad). After adding the row below and restarted MySQL, MySQL automatically repaired the table.
myisam-recover=FORCE,BACKUP
I'm not sure what effect this has on MySQL performance though.
I didn't know that this was an option with MySQL (not very well versed with the application settings).
From our experience, it is all too easy to corrupt the MyISAM tables by having an unexpected shutdown or lockup. I'm going to add that line to our config, as it's definately something that we need to have working.
I do tend to agree with you on the ownership issues though. If MySQL has this functionality built in then I don't know that this needs to be implimented in Hmailserver.
From our experience, it is all too easy to corrupt the MyISAM tables by having an unexpected shutdown or lockup. I'm going to add that line to our config, as it's definately something that we need to have working.
I do tend to agree with you on the ownership issues though. If MySQL has this functionality built in then I don't know that this needs to be implimented in Hmailserver.
One quick question - will this fix tables that are corrupted while MySQL is running?
Our latest issue was the greylisting table became corrupted during a RAID rebuild. This killed Hmailserver, but from what I can tell from your posts above, is that this fixes the tables when MySQL is restarted, rather than on the fly. Is this correct, or does it repair corrupted tables on the fly also?
Our latest issue was the greylisting table became corrupted during a RAID rebuild. This killed Hmailserver, but from what I can tell from your posts above, is that this fixes the tables when MySQL is restarted, rather than on the fly. Is this correct, or does it repair corrupted tables on the fly also?
As far as I can tell from the docs, it's made on the fly. My tests indicated that as well. What I ment with restarting in my previous post was that I had to restart MySQL for the change in my.ini to take effect.
Automatic recovery is activated if you start mysqld with the --myisam-recover option. In this case, when the server opens a MyISAM table, it checks whether the table is marked as crashed or whether the open count variable for the table is not 0 and you are running the server with external locking disabled. If either of these conditions is true, the following happens:
* The server checks the table for errors.
* If the server finds an error, it tries to do a fast table repair (with sorting and without re-creating the data file).
* If the repair fails because of an error in the data file (for example, a duplicate-key error), the server tries again, this time re-creating the data file.
* If the repair still fails, the server tries once more with the old repair option method (write row by row without sorting). This method should be able to repair any type of error and has low disk space requirements.
If the recovery wouldn't be able to recover all rows from previously completed statementas and you didn't specify FORCE in the value of the --myisam-recover option, automatic repair aborts with an error message in the error log.
If the table is "really corrupt", rows may be lost. If you never want the repair function to remove rows, you shouldn't use the FORCE flag.
Automatic recovery is activated if you start mysqld with the --myisam-recover option. In this case, when the server opens a MyISAM table, it checks whether the table is marked as crashed or whether the open count variable for the table is not 0 and you are running the server with external locking disabled. If either of these conditions is true, the following happens:
* The server checks the table for errors.
* If the server finds an error, it tries to do a fast table repair (with sorting and without re-creating the data file).
* If the repair fails because of an error in the data file (for example, a duplicate-key error), the server tries again, this time re-creating the data file.
* If the repair still fails, the server tries once more with the old repair option method (write row by row without sorting). This method should be able to repair any type of error and has low disk space requirements.
If the recovery wouldn't be able to recover all rows from previously completed statementas and you didn't specify FORCE in the value of the --myisam-recover option, automatic repair aborts with an error message in the error log.
If the table is "really corrupt", rows may be lost. If you never want the repair function to remove rows, you shouldn't use the FORCE flag.
Here are a couple of easy ideas to implement:
1) Change the mysql ini file to include the autorepair during the initial install. This will only help new installations with the default MySQL DB, but it is an easy change to make.
2) Check to see if a table is corrupt when hMailServer starts (not while running). If a critical table is corrupt, hMailServer should tell the DB server to repair the corrupted table.
1) Change the mysql ini file to include the autorepair during the initial install. This will only help new installations with the default MySQL DB, but it is an easy change to make.
2) Check to see if a table is corrupt when hMailServer starts (not while running). If a critical table is corrupt, hMailServer should tell the DB server to repair the corrupted table.