Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-8079

DistributedMapCacheClient not properly closing Sockets on connection failure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.15.0
    • Extensions
    • None

    Description

      The DistributedMapCacheClient doesn't always properly close Sockets if it fails to connect. Both the SSLCommsSession and the StandardCommsSession classes have something like this in the constructor:

      socketChannel = SocketChannel.open();
      socketChannel.socket().connect(new InetSocketAddress(hostname, port), timeoutMillis);
       

      If the call to `socketChannel.socket().connect()` throws an Exception, the Socket may or may not be closed, depending on the reason for the failure. We need to ensure that in this case we properly call socketChannel.close().

      We should also check for any other spots where we may follow a similar pattern.

      This issue can be identified because the instance can run out of open file handles. Running `lsof -p <pid>` will show a lot of Socket file handles being used, but `netstat` won't show these because there's no established connection. The `ss` command will include these in the `closed` count.

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              markap14 Mark Payne
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: