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

Ensure next run time is in the future. #53

Closed
wants to merge 1 commit into from

Conversation

peterwilsoncc
Copy link

When rescheduling a task, check the next run time is in the future to prevent the event from looping while it catches up to the current time.

When rescheduling a task, check the next run time is in the future to prevent the event from looping while it catches up to the current time.
@rmccue
Copy link
Member

rmccue commented Aug 27, 2018

This is actually intentional; say you have a job run once a day and it increments a counter, you would want it to bring the counter up to the expected value, rather than skip the jobs you'd expected to run.

Likewise, if you have a job run at a specific time (say, midnight every day), then you want it to always run at that time, rather than moving around. Setting it dynamically means it shifts forward, so you'd eventually end up minutes or hours after you'd expect it to run.

@rmccue rmccue closed this Aug 27, 2018
@rmccue
Copy link
Member

rmccue commented Aug 27, 2018

Whoop, didn't mean to close immediately.

@rmccue rmccue reopened this Aug 27, 2018
@peterwilsoncc
Copy link
Author

you would want it to bring the counter up to the expected value

I guess that makes sense. It's something we could bikeshed all day but I'm happy if you close the PR.

if you have a job run at a specific time (say, midnight every day), then you want it to always run at that time, rather than moving around.

I defaulted to the old next run + interval in an attempt to avoid the drift. The drift should only happen if the event runs longer than the interval or something like wp_schedule_event( 0, 'daily', 'cavalcade_daily' ); is used to register event.

@rmccue
Copy link
Member

rmccue commented Oct 2, 2018

@peterwilsoncc I wonder if we could capture this in a CLI command instead; something like wp cavalcade job restart {id} --skip-backlog?

@peterwilsoncc
Copy link
Author

@rmccue That works for me, I've created an issue on the Cavalcade repo to follow up. humanmade/Cavalcade#68

@peterwilsoncc peterwilsoncc deleted the 51-future-next-run branch October 2, 2018 22:04
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

Successfully merging this pull request may close these issues.

2 participants