Solved

Mysql Error "Lock wait timeout exceeded; try restarting transaction"

Posted on 2010-09-15
9
1,833 Views
Last Modified: 2013-12-12
Hi

I am using Interspire application with Mysql as backend.  From long time am seeing these error in error log:


Lock wait timeout exceeded; try restarting transaction         Internal         Sep 15 2010 07:36:59
        
Query:

UPDATE email_queues SET processed='0' WHERE queueid='3896' AND queuetype='autoresponder' AND sent='0'
Location::
/var/www/html/admin/functions/api/jobs_autoresponders.php (Line 1082)


Mysql 's config files content:
cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

net_read_timeout=120

#[NDBD DEFAULT]
#TransactionDeadlockDetectionTimeout: 5000
innodb_buffer_pool_size=838860800


# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid



Can you help indentifying the root cause of error and hint to fix it ?
0
Comment
Question by:ashwanijain
9 Comments
 
LVL 3

Accepted Solution

by:
AliFarhadi earned 167 total points
ID: 33679935
Looks like something Locked table BEFORE this query and it is blocked for a long time, so the timeout exceeded. There are tho ways:

1. check the logfile and try to determine the periodic of the error - maybe this will help you to find the  Cron-script which lock the table.
2. create an offline script, which will execute "SHOW FULL PROCESSLIST" every X minutes and check if trere are some LOCKED states and longtime UPDATE queries... In this case send a full list of queries to Log ad then check it manually. There should be some query Locked table for some long task (usually updating, maybe with a WHERE case without indexes)
0
 
LVL 29

Assisted Solution

by:Michael W
Michael W earned 167 total points
ID: 33681462
I recommend enabling the slow query log on the MySQL server to see with an in-depth view of where the problem is starting to occur.

Enable MySQL Query Log File
http://linuxwindowsmaster.com/enable-mysql-query-log-file/
0
 
LVL 3

Expert Comment

by:AliFarhadi
ID: 33681823
sometimes queries are marked as SLOW because of waiting in queue, so the viewing of a process list will allow to determine the most first "slow" query which slow execution of all other queries.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:ashwanijain
ID: 33683391
Hi

I have enabled the slow query logging for queries taking more than 10 seconds, lets see which query is it.
0
 
LVL 8

Assisted Solution

by:wolfgang_93
wolfgang_93 earned 166 total points
ID: 33695408
I will guess that email_queues is a MyISAM table.
Locking is very primitive on MyISAM tables.
When anyone issues a query against a MyISAM table, it will put a full table lock
on the table until the query is done.

Here's a command to find out the type of table (look for "Engine"):
  show table status like 'email_queues'\G

Consider converting your table to InnoDB which does row locking like other
traditional database systems such as Oracle, SQL Server, and DB2:

  alter table email_queues engine=innodb;

0
 
LVL 8

Expert Comment

by:wolfgang_93
ID: 33931947
There were some good suggestions here to address a lock-wait timeout issue
including how to find the offending query, how to minimize locking (an probably
avoiding it happening in the first place) by converting the table in question to
InnoDB (my own suggestion).

Moving the server to a new hardware or a newer version of MySQL will not
fix the problem if none of the suggestions suggested here are followed.

Therefore I am against having the question simply deleted and a refund issued.



0
 

Expert Comment

by:_alias99
ID: 34008572
I've distributed the points among the responses provided.

With no response from the author, my reading of the question was that it was looking for troubleshooting assistance.
 
_alias99
Community Support Moderator
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use embargo Date/time in php 29 39
Making API calls from hashed passwords 26 54
Checkout Page Input Field not aligned 1 23
Decrypt string by php 7 32
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question