ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-783

committedLog in ZKDatabase is not properly synchronized

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.3.1
    • Fix Version/s: 3.3.2, 3.4.0
    • Component/s: server
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      ZKDatabase.getCommittedLog() returns a reference to the LinkedList<Proposal> committedLog in ZKDatabase. This is then iterated over by at least one caller.

      I have seen a bug that causes a NPE in LinkedList.clear on committedLog, which I am pretty sure is due to the lack of synchronization. This bug has not been apparent in normal ZK operation, but in code that I have that starts and stops a ZK server in process repeatedly (clear() is called from ZooKeeperServerMain.shutdown()).

      It's better style to defensively copy the list in getCommittedLog, and to synchronize on the list in ZKDatabase.clear.

      1. ZOOKEEPER-783.patch
        0.8 kB
        Henry Robinson

        Activity

        Hide
        Henry Robinson added a comment -

        Defensive copying added to getCommittedLog() and synchronization during clear().

        No tests added; really not sure how best to test for this. It does fix my test case but it's very difficult to distill that into a test (plus it only fails once in about 100 runs).

        Show
        Henry Robinson added a comment - Defensive copying added to getCommittedLog() and synchronization during clear(). No tests added; really not sure how best to test for this. It does fix my test case but it's very difficult to distill that into a test (plus it only fails once in about 100 runs).
        Hide
        Mahadev konar added a comment -

        i think we can do without a test on this one. marking it PA

        Show
        Mahadev konar added a comment - i think we can do without a test on this one. marking it PA
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12446054/ZOOKEEPER-783.patch
        against trunk revision 962697.

        +1 @author. The patch does not contain any @author tags.

        -1 tests included. The patch doesn't appear to include any new or modified tests.
        Please justify why no tests are needed for this patch.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/142/testReport/
        Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/142/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/142/console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12446054/ZOOKEEPER-783.patch against trunk revision 962697. +1 @author. The patch does not contain any @author tags. -1 tests included. The patch doesn't appear to include any new or modified tests. Please justify why no tests are needed for this patch. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/142/testReport/ Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/142/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/142/console This message is automatically generated.
        Hide
        Mahadev konar added a comment -

        +1 the patch looks good!

        Show
        Mahadev konar added a comment - +1 the patch looks good!
        Hide
        Mahadev konar added a comment -

        I just committed this to trunk and 3.3 branch.

        Thanks henry!

        Show
        Mahadev konar added a comment - I just committed this to trunk and 3.3 branch. Thanks henry!
        Hide
        Hudson added a comment -

        Integrated in ZooKeeper-trunk #887 (See http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/887/)
        ZOOKEEPER-783. committedLog in ZKDatabase is not properly synchronized (henry via mahadev)

        Show
        Hudson added a comment - Integrated in ZooKeeper-trunk #887 (See http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/887/ ) ZOOKEEPER-783 . committedLog in ZKDatabase is not properly synchronized (henry via mahadev)

          People

          • Assignee:
            Henry Robinson
            Reporter:
            Henry Robinson
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development