xadisk
  1. xadisk
  2. XADISK-140

Resource leak in XADisk NIO TCP Server

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.2.1, current
    • Fix Version/s: 1.2.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Linux, OpenJDK 7

      Description

      When stress testing XADisks TCP remote filesystem server I found a massive number of TCP connections in my OS were hanging in the CLOSE_WAIT state. The TCP NIO server which is build into XA Disk keeps references to sockets that have been closed by the client causing TCP sockets never to be released and connections to hang in CLOSE_WAIT. I have attached a new version of 'PointOfContact.java' which remedies this problem. I rewrote a large part of it because I had trouble wrapping everything neatly in try / finally blocks to ensure connections are always cleaned up.

        Activity

        Hide
        Jasper Siepkes added a comment -

        Ugh.. apparently you can't attach anything on java.net's Jira...

        Nitin, please send me a message if you want the patch and I'll send it to you.

        Show
        Jasper Siepkes added a comment - Ugh.. apparently you can't attach anything on java.net's Jira... Nitin, please send me a message if you want the patch and I'll send it to you.
        Hide
        Nitin Verma added a comment -

        I have made below addition in the ConversationGateway.java (attached) when it sees the end-of-stream by the client:
        ...
        ...
        context.updateWithConversation(buffer);
        } catch (IOException ioe)

        { selectionKey.cancel(); channel.socket().close();<---added this. }

        ...
        ...

        If you are not able to attach your changes, please send them to me at nitin_verma [AT] java.net.

        Thanks,
        Nitin

        Show
        Nitin Verma added a comment - I have made below addition in the ConversationGateway.java (attached) when it sees the end-of-stream by the client: ... ... context.updateWithConversation(buffer); } catch (IOException ioe) { selectionKey.cancel(); channel.socket().close();<---added this. } ... ... If you are not able to attach your changes, please send them to me at nitin_verma [AT] java.net. Thanks, Nitin
        Hide
        Jasper Siepkes added a comment -

        Hi Nitin,

        Apparently only people with the "Developer" role can add attachments to Jira ( https://weblogs.java.net/blog/edburns/archive/2013/07/15/mojarra-jira-tips?force=954 ) I've E-Mailed you a version of PointOfContact.java which I modified to remedy the above described situation.

        I combined it with "ConversationGateway.java" to make it easier to understand the flow and be able to easier wrap stuff in try - catch - finally blocks to ensure not leaks away. I was also able to remove the Queue in which all the SocketChannel's are stored (which I think was the cause of the resource leaks).

        Let me know if it useful for XADisk.

        Kind regards,

        Jasper Siepkes

        Show
        Jasper Siepkes added a comment - Hi Nitin, Apparently only people with the "Developer" role can add attachments to Jira ( https://weblogs.java.net/blog/edburns/archive/2013/07/15/mojarra-jira-tips?force=954 ) I've E-Mailed you a version of PointOfContact.java which I modified to remedy the above described situation. I combined it with "ConversationGateway.java" to make it easier to understand the flow and be able to easier wrap stuff in try - catch - finally blocks to ensure not leaks away. I was also able to remove the Queue in which all the SocketChannel's are stored (which I think was the cause of the resource leaks). Let me know if it useful for XADisk. Kind regards, Jasper Siepkes
        Hide
        Nitin Verma added a comment -

        Checked-in the changes to trunk.

        Many Thanks to Jasper Siepkes for his efforts on this bug.

        Nitin

        Show
        Nitin Verma added a comment - Checked-in the changes to trunk. Many Thanks to Jasper Siepkes for his efforts on this bug. Nitin

          People

          • Assignee:
            Nitin Verma
            Reporter:
            Jasper Siepkes
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: