Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-3186

bug in barrier example code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • documentation
    • None

    Description

      the code given in the documentation

      while (true) {
          synchronized (mutex) {
              List<String> list = zk.getChildren(root, true);
              if (list.size() < size) {
                  mutex.wait();
              } else {
                  return true;
              }
          }
      }
      

      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            pancheng cheng pan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: