Github user chunhui-shi commented on a diff in the pull request: https://github.com/apache/drill/pull/741#discussion_r99452939 --- Diff: contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/MongoTestSuit.java --- @@ -234,15 +243,25 @@ private static void createDbAndCollections(String dbName, @AfterClass public static void tearDownCluster() throws Exception { - if (mongoClient != null) { - mongoClient.dropDatabase(EMPLOYEE_DB); - mongoClient.close(); - } synchronized (MongoTestSuit.class) { - if (distMode) { - DistributedMode.cleanup(); - } else { - SingleMode.cleanup(); + if (initCount.decrementAndGet() == 0) { --- End diff -- Without Synchronized, there is still chance two threads go into this place. while thread 0 go to here and is in the middle of tearing down cluster, then thread 1 increases initCount to 1 and somehow report error then come to here to decrease initCount and continue... Then we don't know what will happen.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---