CodeIgniter Forums
Database deadlock, error 1213 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database deadlock, error 1213 (/showthread.php?tid=17014)



Database deadlock, error 1213 - El Forum - 03-23-2009

[eluser]little brittle[/eluser]
I am getting an error on my site every now and then with a database deadlock. Here is the complete text of the error:

Code:
Error Number: 1213

Deadlock found when trying to get lock; try restarting transaction

UPDATE `ci_sessions` SET `last_activity` = 1237826089, `session_id` = '330605bba43ff0de03899f68a2de144a' WHERE session_id = 'e64f09136bab7b31ce129084c8453332'

How can I avoid this?


Database deadlock, error 1213 - El Forum - 03-23-2009

[eluser]pistolPete[/eluser]
Which CI version and which datbase driver are you using?


Database deadlock, error 1213 - El Forum - 03-23-2009

[eluser]little brittle[/eluser]
I should have mentioned that, sorry. CI 1.7.1 using MySQL.


Database deadlock, error 1213 - El Forum - 03-23-2009

[eluser]TheFuzzy0ne[/eluser]
I think this might be an issue with your host. They probably aren't running the latest stable version of MySQL.

There's a bug report [url="http://bugs.mysql.com/bug.php?id=27967"]here[/url], but it suggests that the problem has something to do with transactions, which the sessions class does not use.

Are you using InnoDB and not MyISAM? If so, I'd suggest using MyISAM instead.


Database deadlock, error 1213 - El Forum - 02-18-2011

[eluser]slowgary[/eluser]
@TheFuzzyOne

Sorry to resurrect this old post. I'm facing the same deadlock problem. With the number of writes to the sessions table, won't MyISAM perform much worse than InnoDB? Obviously, throwing fatal errors is worse than poor performance, but I'd really like to avoid table-level locking on sessions, it really seems bad.