cancel
Showing results for 
Search instead for 
Did you mean: 

CronJob error

CronJob error

When my cron job runs, I get this error... Anyone know what it means?>

 

 /usr/local/bin/setlock -n /tmp/cronlock.3788746912.219984 sh -c $'/usr/local/php72/bin/php /home/homedir/mydomain.com/bin/magento cron\072run \174 grep -v \042Ran jobs by schedule\042 \076\076 /home/homedir/mydomain.com/var/log/magento.cron.log'

 

 

 

n Mysql.php line 588:

  SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to   
  get lock; try restarting transaction, query was: DELETE FROM `cron_schedule  
  ` WHERE (status = 'success') AND (job_code in ('indexer_reindex_all_invalid  
  ', 'indexer_update_all_views', 'indexer_clean_all_changelogs')) AND (create  
  d_at < '2019-02-20 18:00:03')                                                


In Pdo.php line 235:

  SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to   
  get lock; try restarting transaction, query was: DELETE FROM `cron_schedule  
  ` WHERE (status = 'success') AND (job_code in ('indexer_reindex_all_invalid  
  ', 'indexer_update_all_views', 'indexer_clean_all_changelogs')) AND (create  
  d_at < '2019-02-20 18:00:03')                                                


In Pdo.php line 228:

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

5 REPLIES 5

Re: CronJob error

This sounds like a past cron is still running or holding a lock on your [cron_schedule] table.

 

While this is not a Magento issue per say but rather a MySQL issue, I have in the past resolved this by truncating the [cron_schedule] table and making sure all past crons are not running in the background.

 

Make sure you backup your database before you truncate anything or engage with a system admin or DBA to assist you professionally.

--
Problem solved? Click Accept as Solution!

Re: CronJob error

Hello @alexander_frost 

 

This issue is due to the large number of crons are schedule in the cron_schedule table. We have two steps quick solution for you and it will resolve your issue and also protect your Magento store from this kind of problem in the future.

 

1) First, you need to truncate the table cron_schedule and it will solve this issue.
2) From Index Management and set all the indexes related to catalog to 'manual' and rebuild the indexes manually.

 

I hope, It will resolve your problem.

 

Thanks

 

--
Problem solved? Click Accept as Solution!

Re: CronJob error

hello @Stuart M@PankajS_Magento do we need to stop all cron jobs before truncating the [cron_schedule] table ?

Re: CronJob error

I personally would stop all crons first yes. I don't believe this is a requirement but something I personally do alongside optionally putting the site in maintainance mode.

--
Problem solved? Click Accept as Solution!

Re: CronJob error

Ok the steps worked great, However i got many pending crons?

 

and error shows on system log

Consumer "async.operations.all" skipped as required connection "amqp" is not configured. Unknown connection name amqp 

--------------------------------------------------

this post below solved the problem as of now

https://magento.stackexchange.com/questions/126067/magento-2-how-to-unlock-reindex-process