# Tables get locked and won't unlock

**URL:** <https://forums.percona.com/t/tables-get-locked-and-wont-unlock/434>\
**Category:** Other MySQL® Questions\
**Created:** [September 4, 2007, 2:59pm UTC](https://forums.percona.com/t/tables-get-locked-and-wont-unlock/434 "2007-09-04T14:59:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustinDC](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@JustinDC](https://forums.percona.com/u/JustinDC)\
**Post date:** [September 4, 2007, 2:59pm UTC](https://forums.percona.com/t/tables-get-locked-and-wont-unlock/434/1 "2007-09-04T14:59:37Z")

</div>

Current Server hardware

MySQL Ver 14.12 Distrib 5.0.27  
RHEL vs 5  
584GB Raid 5 storage  
8GB of RAM (I’m working on getting a 64bit OS to install so I can use all 8GB)  
Dual 5130 processors (2.0GHz Intel Dual-Core Xeon)

Current my.cnf

[mysqld]  
datadir=/var/lib/mysql  
socket=/var/lib/mysql/mysql.sock  
wait\_timeout=30  
default-character-set=utf8  
max\_allowed\_packet = 14M  
max\_connections = 600  
ft\_min\_word\_len = 3

key\_buffer\_size = 2000M  
sort\_buffer = 9M  
#read\_rnd\_buffer\_size = 3M

table\_cache = 350

server-id=1  
log-error = /var/log/mysql/error.log  
expire\_logs\_days = 3

# Default to using old password format for compatibility with mysql 3.x

# clients (those using the mysqlclient10 compatibility package).

old\_passwords=0

[mysql.server]  
user=mysql

[mysqld\_safe]  
err-log=/var/log/mysql/mysqld.log  
pid-file=/var/run/mysqld/mysqld.pid

* * *

Everything is stored in MyISAM.

Tables range from small to largest being 500k Rows with size of 1.9GB (incl indexes) which is wrote to constantly.

(any other info I’ll gladly provide if needed).

Here’s my dilemma. The server runs fine for long periods of time.. then all of a sudden tables Lock and queries build up .. and just don’t catch up and easiest thing to do is do a restart of mysql to clear everything out.

I’ve noticed that sometimes when I run a large search on a table after after 60 seconds of searching that table (I’d like to get that down) Tables start locking and won’t unlock unless I kill the Search.

The search is searching over three FULL Text indexes in Boolean mode.

I am thinking my config is screwed up and needs tweaked but I’m at a miss on how to fine tune.

so I seek help here.

thanks.

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forums.percona.com/u/james)\
**Post date:** [September 5, 2007, 8:01am UTC](https://forums.percona.com/t/tables-get-locked-and-wont-unlock/434/2 "2007-09-05T08:01:43Z")

</div>

This is just one thing that I’ve seen cause this. It might not be the problem you’re having.

I’ve seen this happen before when queries get executed on a table in the following order (from different threads):

- A SELECT that takes a long time to execute
- An UPDATE that modifies one of the same tables locked by that select

Any other queries (SELECTs included) that require that table will wait for the UPDATE to complete before they will execute, even if they are very simple queries that should be fast (this is because UPDATEs have higher priority than SELECTs).

I’ve tried UPDATE LOW\_PRIORITY and SELECT HIGH\_PRIORITY when I’ve had this happen in the past, but not with much luck. We ended up reworking our architecture to remove the need for UPDATEs (we use multiple tables, SELECTs, and INSERTs). Obviously that might not work for your application, though.

InnoDB might solve this problem because it supports row locking.

---

<div class="post-metadata">

**Author:** ![JustinDC](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@JustinDC](https://forums.percona.com/u/JustinDC)\
**Post date:** [September 5, 2007, 8:05am UTC](https://forums.percona.com/t/tables-get-locked-and-wont-unlock/434/3 "2007-09-05T08:05:52Z")

</div>

that’s exactly what is happening I bet… the select takes a long time, then an update comes in but can’t lock so it waits and then all new selects lock as well.

gotta love that. thanks for the reply

---

<div class="post-metadata">

**Author:** ![Peter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/peter/32/2_2.png) [@Peter](https://forums.percona.com/u/Peter)\
**Post date:** [September 5, 2007, 8:53am UTC](https://forums.percona.com/t/tables-get-locked-and-wont-unlock/434/4 "2007-09-05T08:53:29Z")

</div>

Yes it is likely to be updates stucking the queue as they are given priority. Check if running with low\_priority\_updates enabled solves the issue.

The other possiblity is stale table lock - when connection locks the table explicitly and then is not closed for a while.
