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

Synchronized block in NIOServerCnxn

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.0
    • Component/s: server
    • Labels:
      None
    • Hadoop Flags:
      Reviewed
    • Release Note:
      not a blocker for 3.2, moving to 3.3

      Description

      There are two synchronized blocks locking on different objects, and to me they should be guarded by the same object. Here are the parts of the code I'm talking about:

      NIOServerCnxn.readRequest@444
      ...
                synchronized (this) {
                      outstandingRequests++;
                      // check throttling
                      if (zk.getInProcess() > factory.outstandingLimit) {
                          disableRecv();
                          // following lines should not be needed since we are already
                          // reading
                          // } else {
                          // enableRecv();
                      }
                  } 
      
      NIOServerCnxn.sendResponse@740
      ...
               synchronized (this.factory) {
                      outstandingRequests--;
                      // check throttling
                      if (zk.getInProcess() < factory.outstandingLimit
                              || outstandingRequests < 1) {
                          sk.selector().wakeup();
                          enableRecv();
                      }
                  }
      

      I think the second one is correct, and the first synchronized block should be guarded by "this.factory".

      This could be related to issue ZOOKEEPER-57, but I have no concrete indication that this is the case so far.

        Attachments

        1. zk-deadlock.png
          24 kB
          Todd Lipcon
        2. ZOOKEEPER-59.patch
          4 kB
          Flavio Paiva Junqueira
        3. ZOOKEEPER-59.patch
          4 kB
          Flavio Paiva Junqueira
        4. ZOOKEEPER-59.patch
          5 kB
          Flavio Paiva Junqueira

          Activity

            People

            • Assignee:
              fpj Flavio Paiva Junqueira
              Reporter:
              fpj Flavio Paiva Junqueira
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: