Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2616

Concurrent ServerSocket creation fails to bind.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Minor
    • 5.2.6
    • None
    • None
    • False
    • None
    • False

    Description

      This is a weird issue that shows up in Infinispan testsuite and causes failure (not sure if it can happen in production, that's why I reduced the priority to minor).

      The tests use the same JGroups with bind_port=7200 and port_range=30. Sometimes, the tests fail to bind to a port although there are enough ports available.

      I did some debugging in method org.jgroups.util.Util#bind(java.net.ServerSocket, java.net.InetAddress, int, int), and I found the following:

      If I get the following exception, everything works as expected and the test is able to bind to the next port

      java.net.BindException: Address already in use (Bind failed)
              at java.net.PlainSocketImpl.socketBind(Native Method) ~[?:?]
              at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436) ~[?:?]
              at java.net.ServerSocket.bind(ServerSocket.java:395) ~[?:?]
              at java.net.ServerSocket.bind(ServerSocket.java:349) ~[?:?]
              at org.jgroups.util.Util.bind(Util.java:4038) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.util.Util.createServerSocket(Util.java:4018) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.blocks.cs.TcpServer.<init>(TcpServer.java:64) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.protocols.TCP.start(TCP.java:101) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
      

      However, if this exception happens (note that it says Listen failed):

      java.net.SocketException: Address already in use (Listen failed)
              at java.net.PlainSocketImpl.socketListen(Native Method) ~[?:?]
              at java.net.AbstractPlainSocketImpl.listen(AbstractPlainSocketImpl.java:448) ~[?:?]
              at java.net.ServerSocket.bind(ServerSocket.java:396) ~[?:?]
              at java.net.ServerSocket.bind(ServerSocket.java:349) ~[?:?]
              at org.jgroups.util.Util.bind(Util.java:4038) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.util.Util.createServerSocket(Util.java:4018) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.blocks.cs.TcpServer.<init>(TcpServer.java:64) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
      

      all the remaining attempts failed with

      {Invalid argument (Bind failed)}
      java.net.SocketException: Invalid argument (Bind failed)
              at java.net.PlainSocketImpl.socketBind(Native Method) ~[?:?]
              at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436) ~[?:?]
              at java.net.ServerSocket.bind(ServerSocket.java:395) ~[?:?]
              at java.net.ServerSocket.bind(ServerSocket.java:349) ~[?:?]
              at org.jgroups.util.Util.bind(Util.java:4038) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.util.Util.createServerSocket(Util.java:4018) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.blocks.cs.TcpServer.<init>(TcpServer.java:64) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
              at org.jgroups.protocols.TCP.start(TCP.java:101) ~[jgroups-5.2.3.Final-SNAPSHOT.jar:5.2.3.Final-SNAPSHOT]
      

      Attachments

        Issue Links

          Activity

            People

              rhn-engineering-bban Bela Ban
              pruivo@redhat.com Pedro Ruivo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: