|
|
|
[
Permlink
| « Hide
]
James Strachan - 25/Oct/06 07:46 AM
You're the first one to notice this issue. I wonder how else to create an exclusive table lock in MySQL. I wonder if they are even supported? It might be we need to use different SQL for MySQL maybe?
I wonder if some SQL statement like the following works for MysQL...
LOCK TABLE foo IN ACCESS EXCLUSIVE MODE; The following should work for MySQL 5.x and the tables that are generated...
SET AUTOCOMMIT = 0; Backported to 4.1 trunk via rev: 518161 and 518164
I'm re-opening this issue because it may be that the fix was unnecessary. In MySQL, SELECT FOR UPDATE only works with InnoDB tables. The default table type in MySQL - MyISAM - does not support SELECT FOR UPDATE - it executes the select, but doesn't hold the lock, resulting in Steven's problem. There's no need for specific MySQL behaviour here.
However, when it comes to creating the tables, MySQL will create the table according to the server's default table type, which is MyISAM unless specific in MySQL's startup config. Ideally, ActiveMQ would specify InnoDB in the CREATE TABLE clause. The current lock statement with MyISAM tables has led to very unstable databases (MySQL 5.x) in our environment. After a few hours of use, the MySQL database becomes progressively slower and eventually no other process can get any database lock. The only option is to kill the slave broker and to restart the database. Has anyone else observed this problem?
Assuming that the change of the MySQL tables from MyISAM to InnoDB does fix this problem, I've created a patch to alter the tables to use InnoDB storage engine. I think using ALTER instead of updating the create statements minimizes the code change. I've tested this patch to make sure that it works, but have not yet ran it over a period of time to see if I observe the kind of database slow down that was evident with MyISAM tables.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||