GithubHelp home page GithubHelp logo

Comments (4)

BrianNichols avatar BrianNichols commented on August 19, 2024

There was a connection leak in version 3.2.0. It has already been fixed in 3.2.1 which was released March 3.

from aerospike-client-java.

tassosl avatar tassosl commented on August 19, 2024

I don't think the leak was plugged completely.

In NodeValidator#validateAlias method a new Connection is constructed. The Connection constructor opens up a socket and input output streams:

            socket.connect(address, timeoutMillis);
            in = socket.getInputStream();
            out = socket.getOutputStream();

Those are only closed if the conn.close() method is invoked. However, if an AerospikeException.Connection is thrown in the Connection constructor, the connection will remain open and will leak, because the connection constructor call isn't part of the try block in the NodeValidator#validateAlias method:

        InetSocketAddress address = new InetSocketAddress(alias.name, alias.port);
        Connection conn = new Connection(address, cluster.getConnectionTimeout());

        try {
                   // code omitted for brevity. 
        }
        catch (Exception e) {
                 // here is where connection is closed, but this won't run if exception happens before try
            conn.close(); 
            throw e;
        }

Between 3.2.0 and 3.2.1 you did plug the leaks that could have happened with command.authenticate(conn...) and Info.request(...) method invocations by wrapping them in the try/catch block that is omitted in the code snippet above.

However, the leak I am talking about is still a potential problem, if an exception is thrown from the code that runs in the Connection constructor.

from aerospike-client-java.

BrianNichols avatar BrianNichols commented on August 19, 2024

Was getInputStream() or getOutputStream() throwing the exception?

This is the only way I can see the socket being connected and then not closed. All other exceptions would mean the socket was never connected, thus does not need to be closed.

Your fix does not address the leak, because conn will still be null in the finally block. The close must be called in the Connection constructor to fix the leak.

from aerospike-client-java.

tassosl avatar tassosl commented on August 19, 2024

Yes, so I staged our application with newest client libraries and the memory issue we were seeing and was attributed to aerospike client connection was gone. This means you fixed the memory leak that was hurting memory consumption in our production systems.

To answer your latest question, yes, I did witness an exception in getInputStream while debugging the memory leak issue locally, having our application (with latest aerospike client libraries) connect to an aerospike server cluster in the cloud (AWS). Now that I think about this case more, I believe it's a far fetched edge case and could only pertain to my local dev system's unique configuration.

You can close this issue and the PR associated with it.

Thank you for your quick responses.

from aerospike-client-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.