2
votes

I'm working with Cake 2.1.2

This is my action in the controller:

$this->News->updateAll(
    array('News.Unread' => 0),
    array('News.Id <=' => $lastNewsId, 'RequestingUserId' => $current['id'])
);

Sometime I've this error and I get 500: [PDOException] SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

I'm sure that in any scripts there aren't locks. What do I have to fix it?

1
Can you post the SQL it generates? - jeremyharris
I have find the problem that cause that. The mysql events. I've some scheduled events, and probably these simple queries(i'm sure no locks on that) make some lock.. I don't know how.. but i'm going to move these queries out from mysql. - Giacom0
having a similar issue with CakePHP 3. I suspect it is due to the fact how CakePHP ORM works - XuDing
Are you using transaction with the function above? - XuDing

1 Answers

0
votes

You could prevent that possibly by changing the engine type on the table to InnoDB.