[SPARK-3106] Fix the race condition issue about Connection and ConnectionManager