Giter VIP home page Giter VIP logo

Comments (8)

tkausl avatar tkausl commented on July 4, 2024

The connection is not closed as in The TCP-Connection to the MySQL-Server is closed. CraftConomy3 uses HikariCP which is a connection-pool, so the close puts the connection you got from getConnection() back into the pool of available connections.

from craftconomy3.

greatman avatar greatman commented on July 4, 2024

The error you get is odd since | Max_used_connections | 25 | is so low it shoudn't be a issue. Craftconomy have a config variable to set the maximum amount of connection it can use. The maximum is set by default to 10. It can be set in the config.yml.

from craftconomy3.

theoilie avatar theoilie commented on July 4, 2024

I understand it's a pool (although I've never used HikariCP), but I notice Tools.closeJDBCConnection(connection); whenever commitConnection is null. I found the Tools class and the method that it calls, which appears to close the connection as one normally closes a MySQL connection in Java, meaning it needs to be opened again next time (and the cycle goes on...).

As you can see in my query dump, the connections with the highest ids (meaning newest, most recently-connected) are from CraftConomy3. I just checked again, and the connection count is over 60,000 with ids in the 60,000s being to the prison_economy database.

Obviously it's not using all these connections since max_user_connections is set to 25 like you pointed out, but it seems like they're just being created and then closed. Regarding the config variable you mentioned, I haven't touched that. The config still shows Poolsize: 10.

from craftconomy3.

greatman avatar greatman commented on July 4, 2024

Ill check if there's a update to HikariCP. Maybe it's a bug in it that creates a boatload of connections or the keepalive being too low. When I close the connection in Tools.closeJDBCConnection, I just tell HikariCP that the connection I just used is free, it then decides if it keeps it or not. Looks like it just decides to scrap it, which is odd since connecting is one of the most expensive stuff to do.

from craftconomy3.

theoilie avatar theoilie commented on July 4, 2024

@greatman I don't see anything having to do with HikariCP in Tools.closeJDBCConnection (https://github.com/greatman/GreatmancodeTools/blob/master/src/main/java/com/greatmancode/tools/utils/Tools.java#L123-L128). That's how one normally closes a connection, so I don't think HikariCP even has any choice but to open it again (or use a different connection) next time CC3 tries to get a connection from its pool.

from craftconomy3.

greatman avatar greatman commented on July 4, 2024

It's normal, I still use normal JDBC stuff when working with HikariCP. It gives me a "proxy" of the actual JDBC connection.

To see, https://github.com/greatman/craftconomy3/blob/master/src/main/java/com/greatmancode/craftconomy3/storage/sql/MySQLEngine.java#L34-L44 creates the HikariCP connection. https://github.com/greatman/craftconomy3/blob/master/src/main/java/com/greatmancode/craftconomy3/storage/sql/MySQLEngine.java#L57 gives me a HikariCP JDBC connection.

from craftconomy3.

theoilie avatar theoilie commented on July 4, 2024

https://github.com/greatman/craftconomy3/blob/master/src/main/java/com/greatmancode/craftconomy3/storage/sql/MySQLEngine.java#L43

Could it be a problem that you set the connection timeout to 5000 ms in the above link? Timing out every 5 seconds seems way too soon. The default connection timeout set by HikariCP is 30 seconds (https://github.com/brettwooldridge/HikariCP/blob/dev/src/main/java/com/zaxxer/hikari/HikariConfig.java#L51). Is there a reason you change it to 5?

from craftconomy3.

greatman avatar greatman commented on July 4, 2024

The connection timeout is for the initial connect, it prevent JDBC stalling trying to get a connection so if after 5s it didn't connect to MySQL, it just drops. The value for waiting before closing is the idle timeout which is set to 10 minutes.

I just updated HikariCP to the latest version and i'm seeing my connections being 1000s in sleep so it looks fine I think.

You can try that version if you want, it is here: https://oss.sonatype.org/content/repositories/snapshots/com/greatmancode/craftconomy3/3.3.1-SNAPSHOT/craftconomy3-3.3.1-20160106.045307-9.jar

from craftconomy3.

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.