From commits-return-6986-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Wed Sep 5 16:16:18 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 38790180654 for ; Wed, 5 Sep 2018 16:16:18 +0200 (CEST) Received: (qmail 8144 invoked by uid 500); 5 Sep 2018 14:16:17 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 8133 invoked by uid 99); 5 Sep 2018 14:16:17 -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; Wed, 05 Sep 2018 14:16:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1301ADFF32; Wed, 5 Sep 2018 14:16:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: andor@apache.org To: commits@zookeeper.apache.org Message-Id: <5dc4be0201e9457ab7e89588dabe7f09@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: zookeeper git commit: ZOOKEEPER-2913: testEphemeralNodeDeletion is flaky Date: Wed, 5 Sep 2018 14:16:17 +0000 (UTC) Repository: zookeeper Updated Branches: refs/heads/branch-3.5 d69c3c201 -> 87a2d458f ZOOKEEPER-2913: testEphemeralNodeDeletion is flaky - The test code is assuming the follower is up to date, which without a `sync` call.when regression,the follower could not catch up with the leader,so the `/e1` patch still exists - this issue is not very easy to reproduce,but we can change the codes in the `FollowerZooKeeperServer.commit() ` ,just like this: ``` Request request = pendingTxns.remove(); if (request.getHdr().getType() == -11) { try { Thread.sleep(200); } catch (InterruptedException e) { } } commitProcessor.commit(request); ``` to slow down the commit to simulate the flaky test,then we can check the correctness of this patch - ----------------------------------------**appendix: zk.sync() doc:**------------------------------------------ > ZooKeeper does not guarantee that at every instance in time, two different clients will have identical views of ZooKeeper data. Due to factors like network delays, one client may perform an update before another client gets notified of the change. Consider the scenario of two clients, A and B. If client A sets the value of a znode /a from 0 to 1, then tells client B to read /a, client B may read the old value of 0, depending on which server it is connected to. If it is important that Client A and Client B read the same value, Client B should should call the sync() method from the ZooKeeper API method before it performs its read. - more detais in [ZOOKEEPER-2913](https://issues.apache.org/jira/browse/ZOOKEEPER-2913) Author: maoling Reviewers: andor@apache.org Closes #608 from maoling/ZOOKEEPER-2913 (cherry picked from commit e7ac12c952b47921bfecbad52112be51f5b9ede5) Signed-off-by: Andor Molnar Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/87a2d458 Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/87a2d458 Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/87a2d458 Branch: refs/heads/branch-3.5 Commit: 87a2d458f336c57b5df15c4542b08c9ccdb22cef Parents: d69c3c2 Author: maoling Authored: Wed Sep 5 16:15:58 2018 +0200 Committer: Andor Molnar Committed: Wed Sep 5 16:16:12 2018 +0200 ---------------------------------------------------------------------- .../server/quorum/EphemeralNodeDeletionTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zookeeper/blob/87a2d458/src/java/test/org/apache/zookeeper/server/quorum/EphemeralNodeDeletionTest.java ---------------------------------------------------------------------- diff --git a/src/java/test/org/apache/zookeeper/server/quorum/EphemeralNodeDeletionTest.java b/src/java/test/org/apache/zookeeper/server/quorum/EphemeralNodeDeletionTest.java index 9edb4be..9546c25 100644 --- a/src/java/test/org/apache/zookeeper/server/quorum/EphemeralNodeDeletionTest.java +++ b/src/java/test/org/apache/zookeeper/server/quorum/EphemeralNodeDeletionTest.java @@ -24,7 +24,10 @@ import static org.junit.Assert.assertNull; import java.io.IOException; import java.net.SocketTimeoutException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.zookeeper.AsyncCallback; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.PortAssignment; import org.apache.zookeeper.ZooDefs.Ids; @@ -147,7 +150,11 @@ public class EphemeralNodeDeletionTest extends QuorumPeerTestBase { // close the session and newly created ephemeral node should be deleted zk.close(); - + + SyncCallback cb = new SyncCallback(); + followerZK.sync(nodePath, cb, null); + cb.sync.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); + nodeAtFollower = followerZK.exists(nodePath, false); // Problem 2: Before fix, after session close the ephemeral node @@ -225,4 +232,13 @@ public class EphemeralNodeDeletionTest extends QuorumPeerTestBase { return new CustomQuorumPeer(); } } + + private static class SyncCallback implements AsyncCallback.VoidCallback { + private final CountDownLatch sync = new CountDownLatch(1); + + @Override + public void processResult(int rc, String path, Object ctx) { + sync.countDown(); + } + } }