diff --git a/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala b/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala index f8afbc81c121..5d24870bbcda 100644 --- a/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala +++ b/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala @@ -385,7 +385,10 @@ private[yarn] class YarnAllocator( this.hostToLocalTaskCountPerResourceProfileId = hostToLocalTaskCountPerResourceProfileId if (resourceProfileToTotalExecs.isEmpty) { - targetNumExecutorsPerResourceProfileId.clear() + // Set target executor number to 0 to cancel pending allocate request. + targetNumExecutorsPerResourceProfileId.keys.foreach { rp => + targetNumExecutorsPerResourceProfileId(rp) = 0 + } allocatorNodeHealthTracker.setSchedulerExcludedNodes(excludedNodes) true } else {