cancel
Showing results for 
Search instead for 
Did you mean: 

Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron:run

SOLVED

Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron:run

Hello,

 

A weird error appeared suddenly on a production site online for almost a year.

 

I've been receiving plenty of e-mails regarding cron errors trying to  :

bin/magento cron:run

 

[Magento\Framework\DB\Adapter\DeadlockException]
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: UPDATE `mgdb_cron_schedule` SET `job_code` = ?, `status` = ?, `messages` = ?, `created_at` = '2018-04-05 23:53:18', `scheduled_at` = '2018-04-05 23:57:00', `executed_at` = ?, `finished_at` = ? WHERE (schedule_id='1620710')

[Zend_Db_Statement_Exception]
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: UPDATE `mgdb_cron_schedule` SET `job_code` = ?, `status` = ?, `messages` = ?, `created_at` = '2018-04-05 23:53:18', `scheduled_at` = '2018-04-05 23:57:00', `executed_at` = ?, `finished_at` = ? WHERE (schedule_id='1620710')

[PDOException]
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

cron:run [--group GROUP] [--bootstrap BOOTSTRAP]

 

If I run the cron manually in PLESK, I get the same error.

 

Another type of mail says :

 

[Magento\Framework\DB\Adapter\DeadlockException]                                                                                                                                            
 SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: DELETE FROM `mgdb_cron_schedule` WHERE (schedule_id='1615656')  

 

I tried to reindex with SSH command, but no change.

 

Any idea on how I could get this fixed please ?

 

I'm using Magento 2.2.3, updated on release, several weeks ago.

 

Best regards,

David

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron

OK,

I think I got this solved so I'll put it here if it can spare some time for other users having the same issue.

 

Second error message got me to the answer.

 

Yesterday I had a problem on the dedicated server, so service was very slow, and mysql service had serious issues. I solved it , but when I just looked at cron_schedule tables, I had about 16000 entries, lots of jobs on queue, so that seemed to cause the problem.

 

I first truncated the table on a dev website to be sure, and it solved the issue.

View solution in original post

4 REPLIES 4

Re: Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron

OK,

I think I got this solved so I'll put it here if it can spare some time for other users having the same issue.

 

Second error message got me to the answer.

 

Yesterday I had a problem on the dedicated server, so service was very slow, and mysql service had serious issues. I solved it , but when I just looked at cron_schedule tables, I had about 16000 entries, lots of jobs on queue, so that seemed to cause the problem.

 

I first truncated the table on a dev website to be sure, and it solved the issue.

Re: Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron

Please share, i have the same issue

Re: Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron

Hello,

Sorry for late answer.

I truncated the cron_schedule table.

And I made a backup before doing that.

Hope it can help.

Re: Magento2: Serialization failure: 1213 Deadlock found when trying to get lock on bin/magento cron

Hi,

But again getting the same errors mail. Now, most of the cron job statuses are missed.


@ShapesGS wrote:

Hello,

Sorry for late answer.

I truncated the cron_schedule table.

And I made a backup before doing that.

Hope it can help.