diff --git a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java index 3a8a0372348..01e832e109f 100644 --- a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java +++ b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java @@ -574,7 +574,12 @@ public class WorkerImpl implements Worker holder -> { cleanStageOutput(stageId, true); // Mark the stage as FINISHED - holder.getStageKernelMap().get(stageId).setStageFinished(); + WorkerStageKernel stageKernel = holder.getStageKernelMap().get(stageId); + if (stageKernel == null) { + log.warn("Stage id [%s] non existent. Unable to mark the stage kernel for it as FINISHED", stageId); + } else { + stageKernel.setStageFinished(); + } } ); }