Skip to content

Offset current time to previously scheduled date#96

Open
omochi wants to merge 1 commit intovapor:mainfrom
omochi:offset-current
Open

Offset current time to previously scheduled date#96
omochi wants to merge 1 commit intovapor:mainfrom
omochi:offset-current

Conversation

@omochi
Copy link

@omochi omochi commented Mar 3, 2021

This patch fixes a bug #94 which I reported.
This is second try to fix it.
First one is #95, but it had some issues.

This patch apply minimum threshold to current time which is used to calculate next scheduled date.
This threshold is come from previously scheduled date.

Example:

First, serve booted at 12:00:32 and schedule first execution at 12:01:00.
Unfortunately, job started at 12:00:59.
But it carries expected scheduled date information which is 12:01:00.
So to calculate next scheduled date,
offset current time 12:00:59 up to 12:01:00.
Then next scheduled date will be 12:02:00.
It can avoid immediately double execution.

Test log:
(I added now= to message to share this. Its not included in patch.)

$ .build/release/Run serve --hostname 0.0.0.0 --port 80 --log debug | grep Kicker  
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:53:00 +0000, now=2021-03-03 17:52:39 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:54:00 +0000, now=2021-03-03 17:52:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:55:00 +0000, now=2021-03-03 17:53:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:56:00 +0000, now=2021-03-03 17:54:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:57:00 +0000, now=2021-03-03 17:55:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:58:00 +0000, now=2021-03-03 17:56:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 17:59:00 +0000, now=2021-03-03 17:57:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 18:00:00 +0000, now=2021-03-03 17:58:59 +0000 (Queues/ScheduledJob.swift:45)
[ DEBUG ] Scheduling JobKickerJob to run at 2021-03-03 18:01:00 +0000, now=2021-03-03 17:59:59 +0000 (Queues/ScheduledJob.swift:45)

It keep to run only once at every minutes.

Please review again @gwynne .

Base automatically changed from master to main March 12, 2021 02:50
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.

1 participant