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

Avoid saving schedules before actually running them with runjob #108

Open
kyriog opened this issue Feb 18, 2019 · 0 comments
Open

Avoid saving schedules before actually running them with runjob #108

kyriog opened this issue Feb 18, 2019 · 0 comments

Comments

@kyriog
Copy link
Contributor

kyriog commented Feb 18, 2019

For now, when we use bin/magento cronjobmanager:runjob, the scheduled task is saved to Magento database before being actually running.
This might cause a race condition in a production environment, if the native cron manager is triggered between schedule creation and schedule actual start from the CLI command.

I'd suggest 3 changes:

  • ScheduleManagement::createSchedule() should no longer save the created schedule to database: it should be caller's responsibility.
  • Update ScheduleManagement::execute() to take a Schedule object instead of a scheduled ID. This would allow the previous created object to be executed, without being saved. This suggestion make require some adaptation, as this method is a part of the WebAPI.
  • ScheduleManagement::execute() should set the Schedule Object State to Schedule::STATUS_RUNNING along setting the Executed At.
@kyriog kyriog changed the title Avoid saving runjob before actually running them Avoid saving schedules before actually running them with runjob Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant