Question

I am facing an interesting issue. I have some custom cronjobs. If I run them manually with magerun2 (n98-magerun), they will be executed with success. If I let Magento to schedule it and execute it, sometimes the cronjob will NOT run. For example, using a tool like Amasty cron tasks, I see that the cronjob is pending. After 2 hours I refresh the page and I don't see any information related to my cronjob (neither in the cron_schedule table or in the var/log/cron.log).

Checking out also the magento.cron.log , I saw the following:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to   
  get lock; try restarting transaction, query was: DELETE FROM `cron_schedule  
  ` WHERE (status = 'error') AND (job_code in ('indexer_reindex_all_invalid',  
   'indexer_update_all_views', 'indexer_clean_all_changelogs')) AND (created_  
  at < '2021-02-02 08:05:07')

The status from where condition, sometimes is pending, sometimes is success, sometimes, like in the above example is error or

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

I found this POST from Magento issues and they said that it is fixed in Magento version 2.3.5, after they changed their mind and they said, it is fixed with Magento: 2.4.1 and the last post is saying that it will be fixed in Magento: 2.4.3. Mostly likely, they will say that it will be fixed in version 2.X.X. Currently, I am running on Magento 2.3.4. Any idea what can I do to prevent this deadlock to happen anymore?

Thank you

No correct solution

OTHER TIPS

my friend.

I have similar problems and i am validating this solution

// in app/etc/env.php
'lock' => [
    'provider' => 'db'
    'config'   => [
       'prefix' => 'new-prefix'
    ]
]

https://twitter.com/willemwigman/status/1177162364308860928

hugs, let's talk

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top