java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

innodb_buffer_pool_size and key_buffer_size
MySQL has very limited memory allocation for cache use. If you are using Atmail with MySQL in production, it is imperative you review and optimize MySQL for your hardware and memory. You can increase performance dramatically and reduce I/O usage by tweaking MySQL to use more of your system memory for the cache and buffers.
The two easy options for increasing performance for mysql are the innodb_buffer_pool_size andkey_buffer_size options. Atmail uses InnoDB tables for the user authentication & log-files, and if you have a large userbase performance can be dramatically improved by increasing the innodb_buffer_pool_size. Other tables such as the UserSettings, Abook, use the MyISAM table format which uses the key_buffer_size option.
For a production machine running all the Atmail services with 2GB of RAM we'd recommend the following option:


innodb_buffer_pool_size=256M
key_buffer_size=256M


innodb_lock_wait_timeout
The default value is 50 seconds. A transaction that tries to access a row that is locked by another InnoDB transaction will hang for at most this many seconds before issuing the following error:
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
When a lock wait timeout occurs, the current statement is not executed. The current transaction is not rolled back. (Until MySQL 5.0.13 InnoDB rolled back the entire transaction if a lock wait timeout happened. You can restore this behavior by starting the server with the --innodb_rollback_on_timeoutoption
By default, the transaction will not be rolled back. It is the responsibility of your application code to decide how to handle this error, whether that's trying again, or rolling back.
Also you can see more details of the event by issuing a "SHOW ENGINE INNODB STATUS" on server after getting this error.


innodb_lock_wait_timeout = 123


Steps to change values in my.cnf file (for below mysql 5.5)
1.    Then take back up my.cnf file which is located on /etc/ folder
2.    Stop the my sql server using commond service mysqld stop
3.    Then open my.cnf file and change

innodb_buffer_pool_size=1024M
key_buffer_size=256M
innodb_lock_wait_timeout = 900

4.    Take back up of all log file /var/lib/mysql/ib_logfile0
5.    And /var/lib/mysql/ib_logfile1
6.    Remove log files from /var/lib/mysql/ (ib_logfile0, ib_logfile1, etc..)
7.    Restart the mysql server service mysqld stop
8.    Check buffer size

Steps to change values in my.cnf file (for above mysql 5.5)


SET GLOBAL innodb_lock_wait_timeout = 120;
               or
SET innodb_lock_wait_timeout = 120;




Comments

Popular posts from this blog

SinglePass Terms of Service

Jasper Report Viruatization

JasperReports Tutorial