This is an automated email from the ASF dual-hosted git repository. kirs pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 9ff34b2bd97 branch-3.0: [Fix](Job)Fix the Calculation of the First Trigger Time and Add a Single-Time Scheduling Compensation Logic #44268 (#44402) 9ff34b2bd97 is described below commit 9ff34b2bd972d5ac0ad40ab1314d0e07290669d9 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Fri Nov 29 19:41:28 2024 +0800 branch-3.0: [Fix](Job)Fix the Calculation of the First Trigger Time and Add a Single-Time Scheduling Compensation Logic #44268 (#44402) Cherry-picked from #44268 Co-authored-by: Calvin Kirs <guoqi...@selectdb.com> --- .../org/apache/doris/job/base/JobExecutionConfiguration.java | 5 +++-- .../apache/doris/job/base/JobExecutionConfigurationTest.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java b/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java index 301222d5434..4c6ef4d2037 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java +++ b/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java @@ -172,9 +172,10 @@ public class JobExecutionConfiguration { long firstTriggerTime = windowStartTimeMs + (intervalMs - ((windowStartTimeMs - startTimeMs) % intervalMs)) % intervalMs; if (firstTriggerTime < currentTimeMs) { - firstTriggerTime += intervalMs; + // Calculate how many intervals to add to get the largest trigger time < currentTimeMs + long intervalsToAdd = (currentTimeMs - firstTriggerTime) / intervalMs; + firstTriggerTime += intervalsToAdd * intervalMs; } - if (firstTriggerTime > windowEndTimeMs) { return timestamps; // Return an empty list if there won't be any trigger time } diff --git a/fe/fe-core/src/test/java/org/apache/doris/job/base/JobExecutionConfigurationTest.java b/fe/fe-core/src/test/java/org/apache/doris/job/base/JobExecutionConfigurationTest.java index 24c486baff8..cce0a93c01d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/job/base/JobExecutionConfigurationTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/job/base/JobExecutionConfigurationTest.java @@ -60,14 +60,22 @@ public class JobExecutionConfigurationTest { Assertions.assertArrayEquals(new Long[]{100L, 700L}, delayTimes.toArray()); delayTimes = configuration.getTriggerDelayTimes( 200000L, 0L, 1100000L); - Assertions.assertEquals(1, delayTimes.size()); - Assertions.assertArrayEquals(new Long[]{500L}, delayTimes.toArray()); + Assertions.assertEquals(2, delayTimes.size()); + Assertions.assertArrayEquals(new Long[]{0L, 500L}, delayTimes.toArray()); delayTimes = configuration.getTriggerDelayTimes( 1001000L, 0L, 1000000L); Assertions.assertEquals(1, delayTimes.size()); timerDefinition.setStartTimeMs(2000L); timerDefinition.setIntervalUnit(IntervalUnit.SECOND); Assertions.assertArrayEquals(new Long[]{2L, 12L}, configuration.getTriggerDelayTimes(100000L, 100000L, 120000L).toArray()); + + timerDefinition.setIntervalUnit(IntervalUnit.SECOND); + long second = 1000L; + timerDefinition.setStartTimeMs(second); + timerDefinition.setInterval(1L); + Assertions.assertEquals(3, configuration.getTriggerDelayTimes(second * 5 + 10L, second * 3, second * 7).size()); + Assertions.assertEquals(3, configuration.getTriggerDelayTimes(second * 5, second * 5, second * 7).size()); + } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org