Skip to content

Commit

Permalink
kagkarlsson#515: fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kamko committed Jan 5, 2025
1 parent 1e9771d commit 65cb952
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ public List<CurrentlyExecuting> getCurrentlyExecutingWithStaleHeartbeat() {
protected void detectDeadExecutions() {
LOG.debug("Deleting executions with unresolved tasks.");

Map<String, Instant> unresolvedTaskToNewestExecution = new HashMap<>();
Map<String, Instant> taskToNewestExecutionTime = new HashMap<>();
schedulerTaskRepository.getScheduledExecutions(
ScheduledExecutionsFilter.all(),
execution ->
unresolvedTaskToNewestExecution.merge(
taskToNewestExecutionTime.merge(
execution.taskInstance.getTaskName(),
execution.executionTime,
(oldValue, newValue) -> oldValue.isAfter(newValue) ? oldValue : newValue));
Expand All @@ -371,7 +371,7 @@ protected void detectDeadExecutions() {
.map(UnresolvedTask::getTaskName)
.filter(
taskName -> {
Instant newestExecution = unresolvedTaskToNewestExecution.get(taskName);
Instant newestExecution = taskToNewestExecutionTime.get(taskName);

if (newestExecution == null) {
// probably deleted by other node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ public void should_delete_executions_with_old_unresolved_tasknames() {

scheduler.schedule(first.instance("id_f"), clock.now());
scheduler.schedule(second.instance("id_s"), clock.now().minus(1, ChronoUnit.DAYS));
scheduler.schedule(second.instance("id_s_2"), clock.now().minus(2, ChronoUnit.DAYS));
assertEquals(0, testableRegistry.getCount(StatsRegistry.SchedulerStatsEvent.UNRESOLVED_TASK));

scheduler.runAnyDueExecutions();
assertEquals(2, testableRegistry.getCount(StatsRegistry.SchedulerStatsEvent.UNRESOLVED_TASK));
assertEquals(3, testableRegistry.getCount(StatsRegistry.SchedulerStatsEvent.UNRESOLVED_TASK));

assertEquals(2, DbUtils.countExecutions(postgres.getDataSource()));
assertEquals(3, DbUtils.countExecutions(postgres.getDataSource()));

scheduler.runDeadExecutionDetection();
assertEquals(2, DbUtils.countExecutions(postgres.getDataSource()));
assertEquals(3, DbUtils.countExecutions(postgres.getDataSource()));

clock.tick(Duration.ofDays(4));
scheduler.runDeadExecutionDetection();
Expand Down

0 comments on commit 65cb952

Please sign in to comment.