1. ZooKeeper
  2. ZOOKEEPER-1357

Zab1_0Test uses hard-wired port numbers. Specifically, it uses the same port for leader in two different tests. The second test periodically fails complaining that the port is still in use.


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.0
    • Fix Version/s: 3.5.0
    • Component/s: tests
    • Labels:


      Here's what I get:

      Testcase: testLeaderInConnectingFollowers took 34.117 sec
      Testcase: testLastAcceptedEpoch took 0.047 sec <----- new test added in ZK-1343
      Testcase: testLeaderInElectingFollowers took 0.004 sec
      Caused an ERROR
      Address already in use
      java.net.BindException: Address already in use
      at java.net.PlainSocketImpl.socketBind(Native Method)
      at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
      at java.net.ServerSocket.bind(ServerSocket.java:328)
      at java.net.ServerSocket.<init>(ServerSocket.java:194)
      at java.net.ServerSocket.<init>(ServerSocket.java:106)
      at org.apache.zookeeper.server.quorum.Leader.<init>(Leader.java:220)
      at org.apache.zookeeper.server.quorum.Zab1_0Test.createLeader(Zab1_0Test.java:711)
      at org.apache.zookeeper.server.quorum.Zab1_0Test.testLeaderInElectingFollowers(Zab1_0Test.java:225)

      Testcase: testNormalFollowerRun took 29.128 sec
      Testcase: testNormalRun took 25.158 sec
      Testcase: testLeaderBehind took 25.148 sec
      Testcase: testAbandonBeforeACKEpoch took 34.029 sec

      My guess is that testLastAcceptedEpoch doesn't properly close the connection before testLeaderInElectingFollowers starts.
      I propose to add

      if (leadThread != null)

      { leadThread.interrupt(); leadThread.join(); }

      to the test.

      In addition, I propose to change the hard-wired ports in Zab1_0Test to use Portassignment.unique() as done in other tests. If I understand correctly the static counter used in unique() to assign ports is initialized once per test file, so it would also prevent the problem I'm seeing here of two tests in the same file trying to use the same port.

      The error can be reproduced using the attached patch (for some reason I don't see the problem in the trunk).

      1. ZOOKEEPER-1357.patch
        2 kB
        Alexander Shraer
      2. ZOOKEEPER-1357-v1.patch
        2 kB
        Alexander Shraer


        Alexander Shraer created issue -
        Alexander Shraer made changes -
        Field Original Value New Value
        Attachment reconfig-8-jan.patch [ 12509972 ]
        Patrick Hunt made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Alexander Shraer made changes -
        Attachment reconfig-8-jan.patch [ 12509972 ]
        Alexander Shraer made changes -
        Attachment ZOOKEEPER-1357.patch [ 12608026 ]
        Alexander Shraer made changes -
        Assignee Alexander Shraer [ shralex ]
        Alexander Shraer made changes -
        Affects Version/s 3.5.0 [ 12316644 ]
        Component/s tests [ 12312427 ]
        Alexander Shraer made changes -
        Attachment ZOOKEEPER-1357-v1.patch [ 12640011 ]
        Michi Mutsuzaki made changes -
        Fix Version/s 3.5.0 [ 12316644 ]
        Michi Mutsuzaki made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]


          • Assignee:
            Alexander Shraer
            Alexander Shraer
          • Votes:
            0 Vote for this issue
            4 Start watching this issue


            • Created: