Why is happening like this, some other thread is holding a record lock on some record (you're updating every record in the table!) for too long, and your thread is being timed out. That's why you got this error.
Your first step to lookup for which queries this problem happened.
Below are some queries to observe transaction status and other data:
show processlist;
SELECT * FROM `information_schema`.`innodb_trx` ORDER BY `trx_started`;
SELECT * FROM `information_schema`.`innodb_locks`;
show variables like 'innodb_lock_wait_timeout';
show variables like '%wait_timeout%';
Above queries help you to find out why the problem occurs.
Now you can check your database transaction isolation level in the mysql using following command:
SELECT @@GLOBAL.tx_isolation, @@tx_isolation, @@session.tx_isolation;
I think all values are set to "REPEATABLE-READ" if you don't configured it yet.
Make sure the database tables are using InnoDB storage engine and READ-COMMITTED transaction isolation level.
Now you can set it to "READ-COMMITTED" for better performance using below command:
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
If the the above configuration is correct then please try to increase the database server innodb_lock_wait_timeout variable to 500 (it's a random value, default value is 50).
Restart MySQL database service for the configuration to take place.
Modify MySQL startup options in the configuration file my.cnf (often named my.ini on Windows), so the transaction level is set to transaction-isolation = READ-COMMITTED.
And
innodb_lock_wait_timeout=500
If this not helps you much, you need and database administration as well as expert to troubleshoot the problem.
No comments:
Post a Comment