diff --git llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/TaskExecutorService.java llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/TaskExecutorService.java index 93b59dcb4e..32fbad5bce 100644 --- llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/TaskExecutorService.java +++ llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/TaskExecutorService.java @@ -429,11 +429,6 @@ public void run() { nextSanityCheck = null; // We are going to do something useful now. try { tryScheduleUnderLock(task); - // Wait queue could have been re-ordered in the mean time because of concurrent task - // submission. So remove the specific task instead of the head task. - if (waitQueue.remove(task)) { - metrics.setExecutorNumQueuedRequests(waitQueue.size()); - } lastKillTimeMs = null; // We have filled the spot we may have killed for (if any). } catch (RejectedExecutionException e) { rejectedException = e; @@ -762,6 +757,11 @@ void tryScheduleUnderLock(final TaskWrapper taskWrapper) throws RejectedExecutio } numSlotsAvailable.decrementAndGet(); metrics.setNumExecutorsAvailable(numSlotsAvailable.get()); + // Wait queue could have been re-ordered in the mean time because of concurrent task + // submission. So remove the specific task instead of the head task. + if (waitQueue.remove(taskWrapper)) { + metrics.setExecutorNumQueuedRequests(waitQueue.size()); + } } private boolean handleScheduleAttemptedRejection(TaskWrapper rejected) {