Ticket #4677 (new enhancement)

Opened 1 year ago

Last modified 2 months ago

Automatic REPAIR TABLE tablename after MySQL error 127

Reported by: markjaquith Assigned to: anonymous
Priority: normal Milestone: 2.8
Component: General Version: 2.2.1
Severity: major Keywords: mysql error 127 repair table
Cc:

Description

Whenever a MySQL error 127 crops up, the solution (for me) has always been to repair the table... and it always works. Should we detect these errors and attempt to repair automatically?

Change History

07/26/07 14:31:49 changed by westi

+1 sounds like a good idea.

Maybe a page like the upgrade page in the admin area which is shown on detection and allows the admin to run the repair.

07/26/07 16:31:29 changed by Nazgul

+1 as a plugin (if that's possible when the DB throws a 127?) -1 as part of the core.

Wordpress is a blogging tool, not a sysadmin tool and therefore (by default) shouldn't pretend to be one.

Also, the 127 error happened/happens for a reason. You should find out why instead of just fixing the symptoms by doing a REPAIR TABLE.

07/27/07 16:21:32 changed by Otto42

You could do this with a plugin. You'll need to extend the $wpdb class to do it. I have not tested any of this, of course...

class my_wpdb extends wpdb {
	// override the print_error function
	function print_error($str = '') {
		if (mysql_errno($this->dbh) == 127 ) {
			// do REPAIR TABLE or whatever
		}
		else { 
			parent::print_error($str);
		}
	}

	// copy constructor to handle the annoying missing table variables problem
	function my_wpdb($old_wpdb) {
		// casting an object to an array returns the vars in the object
		// in the array.. so $vars['posts']='wp_posts'. Handy, no?
		$vars = (array)$old_wpdb;
		extract($vars, EXTR_OVERWRITE);
	}
}
// create a new object for the database
$my_wpdb = new my_wpdb($wpdb);

// assign it back to the main database
$wpdb = $my_wpdb;

That should work, I think. Should work in a plugin too. But of course, it won't work if you get the 127 error before the plugins get loaded.

07/27/07 16:23:23 changed by Otto42

Well, okay, so that extract($vars, EXTR_OVERWRITE); is wrong. Still, you could do it with a loop or something. Just need to make it get all of the variables set in the new object.

03/19/08 11:49:29 changed by ffemtcj

  • milestone changed from 2.5 to 2.6.

03/19/08 16:39:45 changed by ffemtcj

  • milestone changed from 2.6 to 2.7.

No Patch. Moved to 2.7

08/31/08 18:11:54 changed by mrmist

Is this going anywhere? There seems to be 50/50 support for plugin or core functionality.

The user-friendly part of me suggests that it might be a good idea to attempt a repair. The sysadmin in me says that user-level code should not be fiddling with sysadmin functions.

At the very least this should be a configurable option if it's brought in. (So that it could be turned off). I'd say off by default, but that would defeat the point in pretty much every case (I.E where a user isn't techy enough to do it themselves.)

10/14/08 02:18:29 changed by ryan

  • milestone changed from 2.7 to 2.8.