Magento – Optimize Mysql Configuration for deadlock error

magento-1.7MySQL

When i am trying to add product in Magento using Magento API. I am getting the following error:

Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

I have read that this issue is because bad optimization of MySQL’s configuration for InnoDB.

My Mysql server configuration for InnoDB is as follows:

### INNODB_ #
innodb_thread_concurrency=8
innodb_lock_wait_timeout=100
innodb_flush_method=O_DIRECT
innodb_log_files_in_group=2
innodb_log_file_size=64M
innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=2
innodb_file_per_table=1
innodb_buffer_pool_size=512M
innodb_additional_mem_pool_size=8M

Is anyone face the same error before? Is these configuration values are correct ? Please help.

Best Answer

Try to truncate log tables

TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_summary_type`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
TRUNCATE `log_visitor_online` ;

I hope it will solve your problem.