Currently, an application is unregistered from YARN resource manager as a shutdown hook. In the scenario where the shutdown hook does not run (e.g., timeouts, etc.), the application is not unregistered, resulting in YARN resubmitting the application even if it succeeded.
For example, you could see the following on the driver log:
20/04/30 06:20:29 INFO SparkContext: Successfully stopped SparkContext
20/04/30 06:20:29 INFO ApplicationMaster: Final app status: SUCCEEDED, exitCode: 0
20/04/30 06:20:59 WARN ShutdownHookManager: ShutdownHook '$anon$2' timeout, java.util.concurrent.TimeoutException
On the YARN RM side:
2020-04-30 06:21:25,083 INFO org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl: container_1588227360159_0001_01_000001 Container Transitioned from RUNNING to COMPLETED
2020-04-30 06:21:25,085 INFO org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl: Updating application attempt appattempt_1588227360159_0001_000001 with final state: FAILED, and exit status: 0
2020-04-30 06:21:25,085 INFO org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl: appattempt_1588227360159_0001_000001 State change from RUNNING to FINAL_SAVING on event = CONTAINER_FINISHED
You see that the final state of the application becomes FAILED since the container is finished before the application is unregistered.