diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManager.java b/indexing-service/src/main/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManager.java index c3d2feb74038..5dc83038017d 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManager.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManager.java @@ -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); @@ -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) ); } diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManagerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManagerTest.java index 4a0ceccccffa..84382d18b5e2 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManagerTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchTaskManagerTest.java @@ -220,7 +220,7 @@ public void testSupervisorStopsSubmittingJobsWhenSuspended() serviceEmitter.verifyEmitted( "batchSupervisor/tasks/submit/success", ImmutableMap.of("supervisorId", SUPERVISOR_ID_FOO), - 2 + 1 ); }