# My sql error: Lock wait timeout

**URL:** <https://www.ruby-forum.com/t/my-sql-error-lock-wait-timeout/165468>\
**Category:** Rails\
**Created:** [April 14, 2009, 9:33am UTC](https://www.ruby-forum.com/t/my-sql-error-lock-wait-timeout/165468 "2009-04-14T09:33:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sriram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@sriram](https://www.ruby-forum.com/u/sriram)\
**Post date:** [April 14, 2009, 9:33am UTC](https://www.ruby-forum.com/t/my-sql-error-lock-wait-timeout/165468/1 "2009-04-14T09:33:43Z")

</div>

Hello,

I have this application where there are 5 tables.

I have the :dependent =\> :destroy clause in such a way that if an entry  
in the first table is deleted all the “dependent” entries in the next 4  
tables are also destroyed.

The issue is there are thousands of entries in the tables and this is  
taking a lot of time and I get a mysql error:

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

Because of this I am not able to destroy an entry.

I tried increasing the lock wait timeout time in the mysql configuration  
file. But still no improvement.

Any help would be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![sriram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@sriram](https://www.ruby-forum.com/u/sriram)\
**Post date:** [April 14, 2009, 4:39pm UTC](https://www.ruby-forum.com/t/my-sql-error-lock-wait-timeout/165468/2 "2009-04-14T16:39:06Z")

</div>

Do you have the correct indexes set on the tables? It sounds like you  
need to make the the delete operation far faster.

On Apr 14, 12:33 am, Sriram V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
