Currently YarnAllocator will update its managed states like numExecutorsRunning after container is allocated but before executor are successfully launched.
This happened when Spark configuration is wrong (like spark_shuffle aux-service is not configured in NM occasionally), which makes executor fail to launch, or NM lost when NMClient is communicated.
In the current implementation, state will also be updated even executor is failed to launch, this will lead to incorrect state of AM. Also lingering container will only be release after timeout, this will introduce resource waste.
So here we should update the states only after executor is correctly launched, otherwise we should release container ASAP to make it fail fast and retry.