Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron schedule is being duplicated #21380

Closed
udovicic opened this issue Feb 21, 2019 · 13 comments
Closed

Cron schedule is being duplicated #21380

udovicic opened this issue Feb 21, 2019 · 13 comments
Assignees
Labels
Component: Cron Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@udovicic
Copy link
Member

Preconditions (*)

  1. Create empty Magento project using composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:2.2.7 .
  2. Install with something like following: php bin/magento setup:install --base-url="http://www.example.com/" --db-host="db" --db-name="..." --db-user="..." --db-password="..." --admin-firstname="Admin" --admin-lastname="Admin" --admin-email="admin@example.com" --admin-user="admin" --admin-password="..." --language="en_US" --currency="EUR" --timezone="Europe/Zagreb" --use-rewrites="1" --backend-frontname="admin". This is actually blank installation, but lets document just in case.

Steps to reproduce (*)

  1. php bin/magento cron:run
  2. php bin/magento cache:flush
  3. (not sure, but i think you need to wait for 1 min)
  4. php bin/magento cron:run
  5. Execute following on the database: SELECT count(*), job_code, scheduled_at FROM `cron_schedule` GROUP BY job_code, scheduled_at ORDER BY `count(*)` DESC

Expected result (*)

  1. There are no duplicate cron jobs

Actual result (*)

  1. Cron jobs are being duplicated: Same job code at the same time exists multiple times

Note:

This has been reported few times before, but issue has been closed with note that new one should be opened if it still persists.

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Feb 21, 2019

Hi @udovicic. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@udovicic do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 21, 2019
@ghost ghost self-assigned this Feb 21, 2019
@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • Next steps are available in case you are a member of Community Maintainers.

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@ghost
Copy link

ghost commented Feb 21, 2019

Hi @udovicic this is expected behavior, if you have a job that runs every time like * * * * *, magento create a few rows for this job. this is not publicated rows.
deepinscreenshot_select-area_20190221121239

@udovicic
Copy link
Member Author

Hi @engcom-backlog-nazar ,

If you repeat steps 1. - 4. few times, more duplicated rows appear, for an example:

count job_codeJob Code scheduled_at
2 indexer_update_all_views 2019-02-21 10:02:00
2 sales_send_order_invoice_emails 2019-02-21 10:02:00
2 sales_grid_order_invoice_async_insert 2019-02-21 10:02:00
2 catalog_product_outdated_price_values_cleanup 2019-02-21 10:02:00
2 sales_send_order_creditmemo_emails 2019-02-21 10:02:00
2 indexer_reindex_all_invalid 2019-02-21 10:01:00
2 outdated_authentication_failures_cleanup 2019-02-21 10:02:00
2 sales_grid_order_shipment_async_insert 2019-02-21 10:02:00
2 catalog_product_frontend_actions_flush 2019-02-21 10:02:00
2 sales_send_order_shipment_emails 2019-02-21 10:02:00
2 indexer_reindex_all_invalid 2019-02-21 10:02:00
2 sales_grid_order_creditmemo_async_insert 2019-02-21 10:02:00
2 magento_newrelicreporting_cron 2019-02-21 10:02:00
2 sales_send_order_emails 2019-02-21 10:02:00
2 sales_grid_order_async_insert 2019-02-21 10:02:00
2 indexer_update_all_views 2019-02-21 10:01:00
1 sales_grid_order_creditmemo_async_insert 2019-02-21 10:22:00
1 sales_send_order_creditmemo_emails 2019-02-21 10:16:00
1 sales_send_order_emails 2019-02-21 10:04:00
1 sales_grid_order_async_insert 2019-02-21 10:04:00
1 indexer_update_all_views 2019-02-21 10:07:00
1 outdated_authentication_failures_cleanup 2019-02-21 10:12:00
1 sales_send_order_emails 2019-02-21 10:20:00
1 sales_grid_order_async_insert 2019-02-21 10:20:00
1 magento_newrelicreporting_cron 2019-02-21 10:08:00

Most of them are the cases that you have mentioned above, but one of the rows that also showed for me is:

<job name="magento_newrelicreporting_cron" instance="Magento\NewRelicReporting\Model\Cron" method="runCron">
    <schedule>*/2 * * * *</schedule>
</job>

Just an example to show, but I do not think that one should be duplicated.

@ghost
Copy link

ghost commented Feb 21, 2019

@udovicic on you screen you have 2 defferent job starting at the same time waths wrong here ?

@udovicic
Copy link
Member Author

@engcom-backlog-nazar That is not correct, if you check the SQL from description, you will notice that first column shows number of occurrences. Meaning that there is only one job magento_newrelicreporting_cron scheduled for 2019-02-21 10:08:00, but for 2019-02-21 10:02:00 it is scheduled two times.

@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Component: Cron Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Feb 21, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Feb 21, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-backlog-nazar
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-98358, MAGETWO-98359 were created

Issue Available: @engcom-backlog-nazar, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@ghost ghost deleted a comment from ajay2jcommerce Feb 21, 2019
@ghost ghost deleted a comment from nainesh2jcommerce Feb 21, 2019
@ghost ghost deleted a comment from prakash2jcommerce Feb 21, 2019
@ghost ghost deleted a comment from dipti2jcommerce Feb 21, 2019
@ghost ghost deleted a comment from amol2jcommerce Feb 21, 2019
@tomekjordan
Copy link

I can confirm that Magento 2.3.1 creates crazy amounts of duplicated cron tasks, some of them are finished, many are missed, due to duplication. Especially some indexers were not refreshed in Update by Schedule mode. Definitely it should be fixed asap.

@chickenland chickenland self-assigned this Jun 18, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jun 18, 2019

Hi @chickenland. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.


@chickenland
Copy link
Contributor

The issue here (that I can re-create) is the cron running multiple times in the same minute will schedule for that minute over and over - because it completes the task and then reschedules it. The fix I envisage here would be that instead of checking for pending cron tasks, it checks in all non-exited statuses (ie. pending, running or success) - and schedules based on that. Therefore, overlapping, completing/running cron tasks will not re-schedule completing/running cron tasks.

@magento-engcom-team
Copy link
Contributor

Hi @udovicic. Thank you for your report.
The issue has been fixed in #23312 by @chickenland in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.3 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jun 26, 2019
@magento-engcom-team
Copy link
Contributor

Hi @udovicic. Thank you for your report.
The issue has been fixed in #23439 by @ihor-sviziev in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.10 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jul 4, 2019
@sebfie
Copy link

sebfie commented Apr 28, 2023

Why this fix is not present on 2.3+ ? It disappears on 2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cron Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

5 participants