[jira] [Commented] (ZOOKEEPER-3186) bug in barrier example code

2018-11-21 Thread Michael K. Edwards (JIRA)


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

Michael K. Edwards commented on ZOOKEEPER-3186:
---

Appropriate for 3.5.5?

> 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 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)


[jira] [Commented] (ZOOKEEPER-3186) bug in barrier example code

2018-11-11 Thread cheng pan (JIRA)


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

cheng pan commented on ZOOKEEPER-3186:
--

[~maoling]  :(Sorry, I forgot to submit it, now you can see it

> 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 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)


[jira] [Commented] (ZOOKEEPER-3186) bug in barrier example code

2018-11-11 Thread maoling (JIRA)


[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-3186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 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)


[jira] [Commented] (ZOOKEEPER-3186) bug in barrier example code

2018-11-10 Thread cheng pan (JIRA)


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

cheng pan commented on ZOOKEEPER-3186:
--

[~maoling] I have seen your code, it does solve the problem, but I added a 
review, please check it on github

> 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 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)


[jira] [Commented] (ZOOKEEPER-3186) bug in barrier example code

2018-11-09 Thread maoling (JIRA)


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

maoling commented on ZOOKEEPER-3186:


[~pancheng]

Thanks for reporting this issue.I had fixed this bug in the 
[ZOOKEEPER-1011|https://github.com/apache/zookeeper/pull/618] which had not 
been reviewed and merged.

I will nudge this issue.
h1.  

 

> 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 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)