ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-1189

For an invalid snapshot file(less than 10bytes size) RandomAccessFile stream is leaking.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.3
    • Fix Version/s: 3.3.4, 3.4.0, 3.5.0
    • Component/s: server
    • Labels:
      None
    • Hadoop Flags:
      Incompatible change, Reviewed

      Description

      When loading the snapshot, ZooKeeper will consider only the 'snapshots with atleast 10 bytes size'. Otherwsie it will ignore and just return without closing the RandomAccessFile.

      Util.isValidSnapshot() having the following logic. 
             // Check for a valid snapshot
              RandomAccessFile raf = new RandomAccessFile(f, "r");
              // including the header and the last / bytes
              // the snapshot should be atleast 10 bytes
              if (raf.length() < 10) {
                  return false;
              }
      

      Since the snapshot file validation logic is outside try block, it won't go to the finally block and will be leaked.

      Suggestion: Move the validation logic to the try/catch block.

      1. ZOOKEEPER-1189-branch-3.3.patch
        2 kB
        Rakesh R
      2. ZOOKEEPER-1189.patch
        2 kB
        Rakesh R
      3. ZOOKEEPER-1189.1.patch
        2 kB
        Rakesh R

        Activity

        Hide
        Rakesh R added a comment -

        Attached the patch, Please review the fix.

        Show
        Rakesh R added a comment - Attached the patch, Please review the fix.
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12494800/ZOOKEEPER-1189.patch
        against trunk revision 1170886.

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

        +1 tests included. The patch appears to include 3 new or modified tests.

        +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 (version 1.3.9) 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: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/555//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/555//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/555//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/12494800/ZOOKEEPER-1189.patch against trunk revision 1170886. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +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 (version 1.3.9) 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: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/555//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/555//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/555//console This message is automatically generated.
        Hide
        Benjamin Reed added a comment -

        +1 looks great!

        Show
        Benjamin Reed added a comment - +1 looks great!
        Hide
        Patrick Hunt added a comment -

        Let's make sure this is fixed in all active branches (currently 3.3.4, 3.4.0 and 3.5.0 (ie trunk))

        Show
        Patrick Hunt added a comment - Let's make sure this is fixed in all active branches (currently 3.3.4, 3.4.0 and 3.5.0 (ie trunk))
        Hide
        Rakesh R added a comment -

        Improved the testcase: Added assertion message.

        Show
        Rakesh R added a comment - Improved the testcase: Added assertion message.
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12495094/ZOOKEEPER-1189.1.patch
        against trunk revision 1172406.

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

        +1 tests included. The patch appears to include 3 new or modified tests.

        +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 (version 1.3.9) 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: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/561//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/561//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/561//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/12495094/ZOOKEEPER-1189.1.patch against trunk revision 1172406. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +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 (version 1.3.9) 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: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/561//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/561//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/561//console This message is automatically generated.
        Hide
        Rakesh R added a comment -

        Thanks very much Benjamin, Mahadev, Pat for looking at this.

        Show
        Rakesh R added a comment - Thanks very much Benjamin, Mahadev, Pat for looking at this.
        Hide
        Mahadev konar added a comment -

        @rakesh,
        Can you please provide a patch for 3.3 branch? The patch seems to apply to both 3.4 and 3.5 but does not apply to 3.3 branch.

        Show
        Mahadev konar added a comment - @rakesh, Can you please provide a patch for 3.3 branch? The patch seems to apply to both 3.4 and 3.5 but does not apply to 3.3 branch.
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12496448/ZOOKEEPER-1189-branch-3.3.patch
        against trunk revision 1173949.

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

        +1 tests included. The patch appears to include 3 new or modified tests.

        -1 patch. The patch command could not apply the patch.

        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/588//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/12496448/ZOOKEEPER-1189-branch-3.3.patch against trunk revision 1173949. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. -1 patch. The patch command could not apply the patch. Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/588//console This message is automatically generated.
        Hide
        Rakesh R added a comment -

        Hi Mahadev,

        I have attached the patch [ZOOKEEPER-1189-branch-3.3.patch] for the 3.3 branch. Please review this.

        Thanks,
        Rakesh

        Show
        Rakesh R added a comment - Hi Mahadev, I have attached the patch [ZOOKEEPER-1189-branch-3.3.patch] for the 3.3 branch. Please review this. Thanks, Rakesh
        Hide
        Mahadev konar added a comment -

        Thanks Rakesh, will go ahead and commit.

        Show
        Mahadev konar added a comment - Thanks Rakesh, will go ahead and commit.
        Hide
        Mahadev konar added a comment -

        Just committed this. Thanks a lot Rakesh!

        Show
        Mahadev konar added a comment - Just committed this. Thanks a lot Rakesh!
        Hide
        Rakesh R added a comment -

        Thanks Mahadev, for reviewing and committing the patch.

        -Rakesh

        Show
        Rakesh R added a comment - Thanks Mahadev, for reviewing and committing the patch. -Rakesh
        Hide
        Hudson added a comment -

        Integrated in ZooKeeper-trunk #1316 (See https://builds.apache.org/job/ZooKeeper-trunk/1316/)
        ZOOKEEPER-1189. For an invalid snapshot file(less than 10bytes size) RandomAccessFile stream is leaking. (Rakesh R via mahadev)

        mahadev : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1176144
        Files :

        • /zookeeper/trunk/CHANGES.txt
        • /zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/Util.java
        • /zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java
        Show
        Hudson added a comment - Integrated in ZooKeeper-trunk #1316 (See https://builds.apache.org/job/ZooKeeper-trunk/1316/ ) ZOOKEEPER-1189 . For an invalid snapshot file(less than 10bytes size) RandomAccessFile stream is leaking. (Rakesh R via mahadev) mahadev : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1176144 Files : /zookeeper/trunk/CHANGES.txt /zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/Util.java /zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java

          People

          • Assignee:
            Rakesh R
            Reporter:
            Rakesh R
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development