-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Magento version 2.4.6-p3 (but most likely all versions will be affected)
Steps to reproduce
Explanation below how to trigger this with a cronjob from inside core Magento. But the most likely cases will come from 3rd party modules containing cronjobs, that were installed for a while and then removed again.
- Have a Magento shop with MSI modules enabled
- Have a working crontab and have it running for a couple of hours
- Inspect the
cron_schedule
table and notice that the jobinventory_in_store_pickup_sales_send_order_notified_emails
is mentioned many times with statussuccess
- Now, disable all MSI modules in
app/etc/config.php
and runbin/magento setup:upgrade
- Keep the crontab running for a few more hours
- Inspect your
cron_schedule
table again
Expected result
It's expected that all jobs that were successful and having run more than 60 minutes ago are removed from the cron_schedule
table.
Actual result
See that there are still jobs inventory_in_store_pickup_sales_send_order_notified_emails
in the table with status success and being older then 60 minutes. Those don't get cleaned up because the MSI modules are no longer active and calling getJobs()
over here doesn't return jobs from inactive (or removed) modules.
Additional information
Ideally, the cronjob cleanup should also figure out which jobs are in the cron_schedule
table that are no longer found in the system and clean those up as well.
Or maybe this can be added in the existing Recurring data script that exists in the Magento_Cron module, as then it doesn't need to be checked every minute when the cron actually runs. Since removing and disabling modules requires a bin/magento setup:upgrade
call anyway, it might be a good idea to only then check for outdated entries in that table and remove them...
And since the cron_schedule
table receives a lot of queries the entire day, it's beneficial to performance that it contains as few rows as possible. Old data should be cleaned up automatically.
I found this in a shop where we have hundreds of entries from 2021 in the cron_schedule
table for jobs that for a long time no longer existed.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status