[
https://issues.apache.org/jira/browse/TWILL-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14556606#comment-14556606
]
ASF GitHub Bot commented on TWILL-129:
--------------------------------------
Github user henry-cask commented on a diff in the pull request:
https://github.com/apache/incubator-twill/pull/34#discussion_r30921191
--- Diff:
twill-zookeeper/src/test/java/org/apache/twill/internal/zookeeper/LeaderElectionTest.java
---
@@ -278,6 +279,54 @@ public void follower() {
}
}
+ @Test
+ public void testRace() throws InterruptedException {
+ ExecutorService executor = Executors.newFixedThreadPool(2);
+ final AtomicInteger leaderCount = new AtomicInteger(0);
+ final CountDownLatch completeLatch = new CountDownLatch(2);
+
+ // Starts two threads and try to compete for leader and immediate drop
leadership.
+ // This is to test the case when a follower tries to watch for leader
node, but the leader is already gone
+ for (int i = 0; i < 2; i++) {
+ final ZKClientService zkClient =
ZKClientService.Builder.of(zkServer.getConnectionStr()).build();
+ zkClient.startAndWait();
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < 1000; i++) {
+ final CountDownLatch leaderLatch = new CountDownLatch(1);
--- End diff --
Since the latch is created per thread, what is the latch used for?
> Race condition in leader election if leader quitted before follower set the
> watch
> ---------------------------------------------------------------------------------
>
> Key: TWILL-129
> URL: https://issues.apache.org/jira/browse/TWILL-129
> Project: Apache Twill
> Issue Type: Bug
> Components: zookeeper
> Affects Versions: 0.4.0-incubating, 0.5.0-incubating, 0.4.1-incubating
> Reporter: Terence Yim
> Assignee: Terence Yim
> Priority: Blocker
>
> In the LeaderElection implementation, if the leader quit and delete its node
> before the next-in-line follower try to set the watch through the exists()
> call, the follower will fail silently without noticing the leader node is
> gone.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)