Skip to content

Commit

Permalink
Verify state again inside the runnable.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekrb19 committed Dec 20, 2024
1 parent 5403a0f commit 5addd13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ private synchronized void startScheduling()
jobsExecutor.schedule(
() -> {
try {
// Check status inside the runnable again before submitting any tasks
if (status == ScheduledBatchSupervisorSnapshot.BatchSupervisorStatus.SCHEDULER_SHUTDOWN) {
return;
}
lastTaskSubmittedTime = DateTimes.nowUtc();
submitSqlTask(supervisorId, spec);
emitMetric("batchSupervisor/tasks/submit/success", 1);
Expand All @@ -264,7 +268,7 @@ private void emitMetric(final String metricName, final int value)
ServiceMetricEvent.builder()
.setDimension("supervisorId", supervisorId)
.setDimension("dataSource", dataSource)
.setMetric(metricName, 1)
.setMetric(metricName, value)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void testSupervisorStopsSubmittingJobsWhenSuspended()
serviceEmitter.verifyEmitted(
"batchSupervisor/tasks/submit/success",
ImmutableMap.of("supervisorId", SUPERVISOR_ID_FOO),
2
1
);
}

Expand Down

0 comments on commit 5addd13

Please sign in to comment.