Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0DF8818953 for ; Fri, 16 Oct 2015 20:41:56 +0000 (UTC) Received: (qmail 11323 invoked by uid 500); 16 Oct 2015 20:41:56 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 11295 invoked by uid 500); 16 Oct 2015 20:41:55 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 11286 invoked by uid 99); 16 Oct 2015 20:41:55 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2015 20:41:55 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 7BDA0C0EB6 for ; Fri, 16 Oct 2015 20:41:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.771 X-Spam-Level: X-Spam-Status: No, score=0.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id iODt5bRcc9kB for ; Fri, 16 Oct 2015 20:41:46 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 31B0526B69 for ; Fri, 16 Oct 2015 20:41:43 +0000 (UTC) Received: (qmail 8835 invoked by uid 99); 16 Oct 2015 20:41:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2015 20:41:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DEE76E13E1; Fri, 16 Oct 2015 20:41:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Date: Fri, 16 Oct 2015 20:41:57 -0000 Message-Id: <24fd3e9a65e3486a982c7f0e10201e90@git.apache.org> In-Reply-To: <95c7941e4a5d4eb8ad528cab2ad71fba@git.apache.org> References: <95c7941e4a5d4eb8ad528cab2ad71fba@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/50] [abbrv] incubator-geode git commit: [GEODE-329] fix ShutdownAllDUnitTest failure [GEODE-329] fix ShutdownAllDUnitTest failure There's a race condition that there will be 2 distributed systems are created in one JVM. When a DS is disconnecting, the current thread stays in wait(500) and release the lock. Thread2 comes and found a disconnected DS, so it will create a new DS. When the current thread waked up, it should double check if the DS has been changed. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/27eceb1f Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/27eceb1f Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/27eceb1f Branch: refs/heads/feature/GEODE-291 Commit: 27eceb1f49647df2207bcc966ba11631a4f5832e Parents: f50ca04 Author: zhouxh Authored: Mon Sep 21 14:56:17 2015 -0700 Committer: zhouxh Committed: Tue Sep 29 15:21:55 2015 -0700 ---------------------------------------------------------------------- .../gemfire/distributed/DistributedSystem.java | 38 ++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/27eceb1f/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java index b7b2cd8..21be43f 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java @@ -1584,32 +1584,34 @@ public abstract class DistributedSystem implements StatisticsFactory { } } else { - if (!existingSystems.isEmpty()) { + boolean existingSystemDisconnecting = true; + while (!existingSystems.isEmpty() && existingSystemDisconnecting) { Assert.assertTrue(existingSystems.size() == 1); InternalDistributedSystem existingSystem = - (InternalDistributedSystem) existingSystems.get(0); - if (existingSystem.isDisconnecting()) { - while (existingSystem.isConnected()) { - boolean interrupted = Thread.interrupted(); - try { - existingSystemsLock.wait(500); - } - catch (InterruptedException ex) { - interrupted = true; - } - finally { - if (interrupted) { - Thread.currentThread().interrupt(); - } + (InternalDistributedSystem) existingSystems.get(0); + existingSystemDisconnecting = existingSystem.isDisconnecting(); + if (existingSystemDisconnecting) { + boolean interrupted = Thread.interrupted(); + try { + // no notify for existingSystemsLock, just to release the sync + existingSystemsLock.wait(50); + } + catch (InterruptedException ex) { + interrupted = true; + } + finally { + if (interrupted) { + Thread.currentThread().interrupt(); } } - } - - if (existingSystem.isConnected()) { + } else if (existingSystem.isConnected()) { existingSystem.validateSameProperties(config, existingSystem.isConnected()); return existingSystem; + } else { + // This should not happen: existingSystem.isConnected()==false && existingSystem.isDisconnecting()==false + throw new AssertionError("system should not be disconnecting==false and isConnected==falsed"); } } }