diff --git a/core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala b/core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala index 4e7bf51fc062..65e848bc90a0 100644 --- a/core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala +++ b/core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala @@ -315,7 +315,7 @@ private[spark] class ExecutorAllocationManager( */ private def updateNumExecutorsPending(newTotalExecutors: Int): Int = { val newNumExecutorsPending = - newTotalExecutors - executorIds.size + executorsPendingToRemove.size + math.max(0, newTotalExecutors - executorIds.size + executorsPendingToRemove.size) val delta = newNumExecutorsPending - numExecutorsPending numExecutorsPending = newNumExecutorsPending delta