-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[kie-roadmap-119] Scheduled jobs do not keep configured execution time #2292
Conversation
jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/BasicExecutorBaseTest.java
Outdated
Show resolved
Hide resolved
jbpm-services/jbpm-executor/src/main/java/org/jbpm/executor/commands/LogCleanupCommand.java
Outdated
Show resolved
Hide resolved
jbpm-services/jbpm-executor/src/main/java/org/jbpm/executor/commands/LogCleanupCommand.java
Outdated
Show resolved
Hide resolved
facfffe
to
d230dfe
Compare
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinweiler Good work! I think there's an edge scenario that can be handled (nextScheduleTimeAdd is negative after subtraction). Other two minor comments and also you could rebase it as we are in the next snapshot now.
jbpm-services/jbpm-executor/src/main/java/org/jbpm/executor/commands/LogCleanupCommand.java
Outdated
Show resolved
Hide resolved
jbpm-services/jbpm-executor/src/main/java/org/jbpm/executor/commands/LogCleanupCommand.java
Outdated
Show resolved
Hide resolved
|
||
String nextRun = (String) ctx.getData("NextRun"); | ||
if (nextRun != null) { | ||
nextScheduleTimeAdd = DateTimeUtils.parseDateAsDuration(nextRun) - calculateExecutionTimeInMillis(ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose that the subtraction is negative (because the cleanup operation lasts too long or the interval is very short): in that case, the nextScheduleTimeAdd
is negative, and therefore getScheduleTime
will return null, without scheduling any other time.
I think this edge scenario could be handled as well, wdyt? (also a test with more delay to verify that the cleanup execution is not stopped).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmunozfe thanks for the input, that makes sense. I added the check that in case there is an overlap (previous execution took longer than nextRun value), the next execution is scheduled immediately. Also added a new test case for this scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinweiler thanks, this looks great!
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, astounding work @martinweiler !
Could you add the labels for automatic backporting to 7.67.x and blue? I think with that it's ready to merge
Thank you @gmunozfe ! I have added the labels now. |
#2292) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value
#2292) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value
#2292) (#2309) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value Co-authored-by: Martin Weiler <[email protected]>
#2292) (#2308) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value Co-authored-by: Martin Weiler <[email protected]>
kiegroup#2292) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value
kiegroup#2292) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value
kiegroup#2292) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value
kiegroup#2292) * [kie-roadmap-119] Scheduled jobs do not keep configured execution time * [kie-roadmap-119] Make sure job gets rescheduled even if execution time exceeds nextRun value
When scheduling a LogCleanupCommand with NextRun=1d, the actual execution time for the next run is calculated as (current command execution time + nextRun value). Over time, this can lead to the scheduled execution time to slip, ie. a job scheduled initially at 00:00 gets executed at 00:10, and the execution could be outside of a designated maintenance window.
The expectation is that subsequent executions happen at the defined start time + nextRun value, ie. a job scheduled initially at 00:00 with NextRun=1d should always run at 00:00, regardless of how long it takes to execute it.