Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is it possible to have deadlocks without transactions?

My code is a bit of a mess, I'm not sure where the problem is, but I'm getting deadlocks without using any transactions or table locking. Any information about this would help.

I've looked up deadlocks and it seems the only way to cause them is by using transactions.

Error Number: 1213
Deadlock found when trying to get lock; try restarting transaction
UPDATE `x__cf_request` SET `contact_success` = 1, `se_engine_id` = 0, `is_fresh` = 1 WHERE `id` =  '28488'

Edit: Why downvotes? It's a valid question. If it's impossible just say why, so that other people can see when they run into this issue.

like image 663
Farzher Avatar asked Jul 09 '13 15:07

Farzher


1 Answers

In InnoDB each statement is run in a transation; BEGIN and autocommit=0 are used for multi-statement transactions. Having said that, the deadlock happens between different transactions.

It seems you don't have index on the id field, or more than one record have the same id. If not, than you have an index-gap locking in place. To diagnose further, you need to provide the output of SHOW ENGINE InnoDB STATUS

like image 126
Maxim Krizhanovsky Avatar answered Sep 19 '22 19:09

Maxim Krizhanovsky