Comment posting on WordPress site has stopped working. Instead of displaying saved comment, “page not found” page was shown. URL redirection was also strange comment-page-/#comment- (something I never saw). Comment posting is a very important part of my blog so I have started repairing it immediately.
To collect more informations, I opened Web inspector in Google Chrome and analyzed network traffic after comment was submitted to the server. Here is a snippet from client request and server response.
FORM DATA author:test email:firstname.lastname@example.org url: comment:test ... Response Headers: Content-Type:text/html Date:Fri, 13 Jul 2012 06:10:39 GMT Location:http://www.redips.net/linux/remove-password-vm-manager/comment-page-/#comment- ...
URL redirection indicates that PHP couldn’t read last saved comment from the database. Google also knows a lot of documents regarding keywords: comment-page-/#comment-” wordpress page not found that might be helpful. So the next step was to see status of tables in database:
mysql> show table status from my_database; ... | wp_comments | NULL | ... | Table 'wp_comments' is marked as crashed and should be repaired | ...
wp_comments table was marked as crashed and didn’t have listed any parameter. All parameters were set to NULL with displayed error in the last column. The reason why this has happened may be in running out of disk space or a similar unexpected event. Anyway, cause of the problem was found. PHP couldn’t write or read from wp_comments table and that caused all the problems later (submited comments was not shown and redirection URL was faulty). I tried to make dump before table repaire but that was not possible:
bash> mysqldump -p my_database > my_database.sql Enter password: mysqldump: Got error: 1194: Table 'wp_comments' is marked as crashed and should be repaired when using LOCK TABLES
I had a recent backup so this was not so critical for me if something goes wrong (be sure to have backup just for any case). Here is a MySQL repair command that should fix the wp_comments table:
mysql> use my_database; mysql> repair table wp_comments;
I was not able to run “repair table” because number of maximum MySQL connections exceeded on shared host so I contacted my hosting company and ask them to fix wp_comments table. Minute later they send me a message that table is fixed and everything is fine. Fortunately, my database was successfully repaired and the very next step was taking a backup! And just to mention that comments have started to working flawlessly.