# Mysql::Error: Lock wait timeout exceeded;

**URL:** <https://www.ruby-forum.com/t/mysql-lock-wait-timeout-exceeded/126673>\
**Category:** Deployment\
**Created:** [January 21, 2008, 10:11am UTC](https://www.ruby-forum.com/t/mysql-lock-wait-timeout-exceeded/126673 "2008-01-21T10:11:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stanislavb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@stanislavb](https://www.ruby-forum.com/u/stanislavb)\
**Post date:** [January 21, 2008, 10:11am UTC](https://www.ruby-forum.com/t/mysql-lock-wait-timeout-exceeded/126673/1 "2008-01-21T10:11:42Z")

</div>

Hi,

My application throws some “Mysql::Error: Lock wait timeout” from time  
to time. I think it coincides with the upgrade of Rails to version 2.0.2  
.

# The exact error is this:

# Mysql::Error: Lock wait timeout exceeded; try restarting transaction: INSERT INTO `sessions` (`updated_at`, `session_id`, `data`) VALUES(‘2008-01-20 06:31:40’, ‘34264f71fed074a320ed77dda7a86bda’, ‘BAh7CDoKdG9waWMiEdCS0YHQuNGH0LrQuDoPc3Zlam9fdHlwZSIKZnJlc2gi\nCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7\nAAY6CkB1c2VkewA=\n’) /usr/lib64/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/connection\_adapters/abstract\_adapter.rb:150:in `log’

The sessions table has been generated by rake.

Can anyone give me a clue what could be locking the table.

10x in advance

---

<div class="post-metadata">

**Author:** ![stanislavb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@stanislavb](https://www.ruby-forum.com/u/stanislavb)\
**Post date:** [January 21, 2008, 10:48am UTC](https://www.ruby-forum.com/t/mysql-lock-wait-timeout-exceeded/126673/2 "2008-01-21T10:48:13Z")

</div>

How many hits / second are you servicing ? How much load is your db  
under ? How well tuned is your db, etc. The lock timeout is most  
likely caused by other rails processes contenting for the write lock  
on that table, probably inside a transaction.

mysql\> show innodb status\G

will show you details about the last deadlock or lock timeout, this  
will give you a clue as to the other writers to this table.

mysql\> show table status like ‘sessions’;

will tell you the details about the sessions table, if it isn’t innodb  
then you can only have a single writer to the table, and under heavy  
load this will be a problem.

Cheers

Dave

On Jan 21, 8:11 pm, Stanislav B. \<ruby-forum-incom…@andreas-

---

<div class="post-metadata">

**Author:** ![stanislavb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@stanislavb](https://www.ruby-forum.com/u/stanislavb)\
**Post date:** [January 22, 2008, 2:14am UTC](https://www.ruby-forum.com/t/mysql-lock-wait-timeout-exceeded/126673/3 "2008-01-22T02:14:12Z")

</div>

Howdy. Take a look at this article:

> **[Pitfalls of converting to InnoDB](https://www.percona.com/blog/pitfalls-of-converting-to-innodb/)**
>
> We often recommend to our clients to convert their current database from MyISAM tables to InnoDB. The transfer by itself in most cases is almost plain, however the application can be broken by new unexpected errors 1205 (ER\_LOCK\_WAIT\_TIMEOUT) Lock...

–  
– Tom M., CTO  
– Engine Y., Ruby on Rails Hosting  
– Support, Scalability, Reliability  
– (866) 518-YARD (9273) x201

On Jan 21, 4:11 am, Stanislav B. \<ruby-forum-incom…@andreas-
