zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "maoling (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ZOOKEEPER-3186) bug in barrier example code
Date Mon, 12 Nov 2018 07:11:00 GMT

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-3186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683314#comment-16683314
] 

maoling commented on ZOOKEEPER-3186:
------------------------------------

[~pancheng]

Pardon me,where can i find your review comments?

> bug in barrier example code
> ---------------------------
>
>                 Key: ZOOKEEPER-3186
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3186
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: documentation
>            Reporter: cheng pan
>            Priority: Major
>
> the code given in the documentation
> {code:java}
> while (true) {
>     synchronized (mutex) {
>         List<String> list = zk.getChildren(root, true);
>         if (list.size() < size) {
>             mutex.wait();
>         } else {
>             return true;
>         }
>     }
> }
> {code}
> When some nodes are not ready, the code calls mutex.wait() and waits for the watcher
event to call mutex.notify() to wake it up. The problem is, we can't guarantee that mutex.notify()
will definitely happen after mutex.wait(), which will cause client is stuck.
> The solution might be CountDownLatch?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message