光 HikariCP・A solid, high-performance, JDBC connection pool at last.

Overview

HikariCP It's Faster.Hi·ka·ri [hi·ka·'lē] (Origin: Japanese): light; ray.


Fast, simple, reliable. HikariCP is a "zero-overhead" production ready JDBC connection pool. At roughly 130Kb, the library is very light. Read about how we do it here.

   "Simplicity is prerequisite for reliability."
         - Edsger Dijkstra


Index


Artifacts

Java 8 thru 11 maven artifact:

    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>4.0.3</version>
    </dependency>

Java 7 maven artifact (maintenance mode):

    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP-java7</artifactId>
        <version>2.4.13</version>
    </dependency>

Java 6 maven artifact (maintenance mode):

    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP-java6</artifactId>
        <version>2.3.13</version>
    </dependency>

Or download from here.


🏁 JMH Benchmarks

Microbenchmarks were created to isolate and measure the overhead of pools using the JMH microbenchmark framework. You can checkout the HikariCP benchmark project for details and review/run the benchmarks yourself.

  • One Connection Cycle is defined as single DataSource.getConnection()/Connection.close().
  • One Statement Cycle is defined as single Connection.prepareStatement(), Statement.execute(), Statement.close().
1 Versions: HikariCP 2.6.0, commons-dbcp2 2.1.1, Tomcat 8.0.24, Vibur 16.1, c3p0 0.9.5.2, Java 8u111
2 Intel Core i7-3770 CPU @ 3.40GHz
3 Uncontended benchmark: 32 threads/32 connections, Contended benchmark: 32 threads, 16 connections
4 Apache Tomcat fails to complete the Statement benchmark when the Tomcat StatementFinalizer is used due to excessive garbage collection times
5 Apache DBCP fails to complete the Statement benchmark due to excessive garbage collection times

🔬 Analyses

Spike Demand Pool Comparison

Analysis of HikariCP v2.6, in comparison to other pools, in relation to a unique "spike demand" load.

The customer's environment imposed a high cost of new connection acquisition, and a requirement for a dynamically-sized pool, but yet a need for responsiveness to request spikes. Read about the spike demand handling here.

You're [probably] doing it wrong

AKA "What you probably didn't know about connection pool sizing". Watch a video from the Oracle Real-world Performance group, and learn about why connection pools do not need to be sized as large as they often are. In fact, oversized connection pools have a clear and demonstrable negative impact on performance; a 50x difference in the case of the Oracle demonstration. Read on to find out.

WIX Engineering Analysis

We'd like to thank the guys over at WIX for the unsolicited and deep write-up about HikariCP on their engineering blog. Take a look if you have time.


Failure: Pools behaving badly

Read our interesting "Database down" pool challenge.


"Imitation Is The Sincerest Form Of Plagiarism" - anonymous

Open source software like HikariCP, like any product, competes in the free market. We get it. We understand that product advancements, once public, are often co-opted. And we understand that ideas can arise from the zeitgeist; simultaneously and independently. But the timeline of innovation, particularly in open source projects, is also clear and we want our users to understand the direction of flow of innovation in our space. It could be demoralizing to see the result of hundreds of hours of thought and research co-opted so easily, and perhaps that is inherent in a free marketplace, but we are not demoralized. We are motivated; to widen the gap.


👪 User Testimonials





⚙️ Configuration (knobs, baby!)

HikariCP comes with sane defaults that perform well in most deployments without additional tweaking. Every property is optional, except for the "essentials" marked below.

📎  HikariCP uses milliseconds for all time values.

🚨  HikariCP relies on accurate timers for both performance and reliability. It is imperative that your server is synchronized with a time-source such as an NTP server. Especially if your server is running within a virtual machine. Why? Read more here. Do not rely on hypervisor settings to "synchronize" the clock of the virtual machine. Configure time-source synchronization inside the virtual machine. If you come asking for support on an issue that turns out to be caused by lack time synchronization, you will be taunted publicly on Twitter.

Essentials

🔤 dataSourceClassName
This is the name of the DataSource class provided by the JDBC driver. Consult the documentation for your specific JDBC driver to get this class name, or see the table below. Note XA data sources are not supported. XA requires a real transaction manager like bitronix. Note that you do not need this property if you are using jdbcUrl for "old-school" DriverManager-based JDBC driver configuration. Default: none

- or -

🔤 jdbcUrl
This property directs HikariCP to use "DriverManager-based" configuration. We feel that DataSource-based configuration (above) is superior for a variety of reasons (see below), but for many deployments there is little significant difference. When using this property with "old" drivers, you may also need to set the driverClassName property, but try it first without. Note that if this property is used, you may still use DataSource properties to configure your driver and is in fact recommended over driver parameters specified in the URL itself. Default: none


🔤 username
This property sets the default authentication username used when obtaining Connections from the underlying driver. Note that for DataSources this works in a very deterministic fashion by calling DataSource.getConnection(*username*, password) on the underlying DataSource. However, for Driver-based configurations, every driver is different. In the case of Driver-based, HikariCP will use this username property to set a user property in the Properties passed to the driver's DriverManager.getConnection(jdbcUrl, props) call. If this is not what you need, skip this method entirely and call addDataSourceProperty("username", ...), for example. Default: none

🔤 password
This property sets the default authentication password used when obtaining Connections from the underlying driver. Note that for DataSources this works in a very deterministic fashion by calling DataSource.getConnection(username, *password*) on the underlying DataSource. However, for Driver-based configurations, every driver is different. In the case of Driver-based, HikariCP will use this password property to set a password property in the Properties passed to the driver's DriverManager.getConnection(jdbcUrl, props) call. If this is not what you need, skip this method entirely and call addDataSourceProperty("pass", ...), for example. Default: none

Frequently used

autoCommit
This property controls the default auto-commit behavior of connections returned from the pool. It is a boolean value. Default: true

connectionTimeout
This property controls the maximum number of milliseconds that a client (that's you) will wait for a connection from the pool. If this time is exceeded without a connection becoming available, a SQLException will be thrown. Lowest acceptable connection timeout is 250 ms. Default: 30000 (30 seconds)

idleTimeout
This property controls the maximum amount of time that a connection is allowed to sit idle in the pool. This setting only applies when minimumIdle is defined to be less than maximumPoolSize. Idle connections will not be retired once the pool reaches minimumIdle connections. Whether a connection is retired as idle or not is subject to a maximum variation of +30 seconds, and average variation of +15 seconds. A connection will never be retired as idle before this timeout. A value of 0 means that idle connections are never removed from the pool. The minimum allowed value is 10000ms (10 seconds). Default: 600000 (10 minutes)

keepaliveTime
This property controls how frequently HikariCP will attempt to keep a connection alive, in order to prevent it from being timed out by the database or network infrastructure. This value must be less than the maxLifetime value. A "keepalive" will only occur on an idle connection. When the time arrives for a "keepalive" against a given connection, that connection will be removed from the pool, "pinged", and then returned to the pool. The 'ping' is one of either: invocation of the JDBC4 isValid() method, or execution of the connectionTestQuery. Typically, the duration out-of-the-pool should be measured in single digit milliseconds or even sub-millisecond, and therefore should have little or no noticible performance impact. The minimum allowed value is 30000ms (30 seconds), but a value in the range of minutes is most desirable. Default: 0 (disabled)

maxLifetime
This property controls the maximum lifetime of a connection in the pool. An in-use connection will never be retired, only when it is closed will it then be removed. On a connection-by-connection basis, minor negative attenuation is applied to avoid mass-extinction in the pool. We strongly recommend setting this value, and it should be several seconds shorter than any database or infrastructure imposed connection time limit. A value of 0 indicates no maximum lifetime (infinite lifetime), subject of course to the idleTimeout setting. The minimum allowed value is 30000ms (30 seconds). Default: 1800000 (30 minutes)

🔤 connectionTestQuery
If your driver supports JDBC4 we strongly recommend not setting this property. This is for "legacy" drivers that do not support the JDBC4 Connection.isValid() API. This is the query that will be executed just before a connection is given to you from the pool to validate that the connection to the database is still alive. Again, try running the pool without this property, HikariCP will log an error if your driver is not JDBC4 compliant to let you know. Default: none

🔢 minimumIdle
This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. If the idle connections dip below this value and total connections in the pool are less than maximumPoolSize, HikariCP will make a best effort to add additional connections quickly and efficiently. However, for maximum performance and responsiveness to spike demands, we recommend not setting this value and instead allowing HikariCP to act as a fixed size connection pool. Default: same as maximumPoolSize

🔢 maximumPoolSize
This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend. A reasonable value for this is best determined by your execution environment. When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up to connectionTimeout milliseconds before timing out. Please read about pool sizing. Default: 10

📈 metricRegistry
This property is only available via programmatic configuration or IoC container. This property allows you to specify an instance of a Codahale/Dropwizard MetricRegistry to be used by the pool to record various metrics. See the Metrics wiki page for details. Default: none

📈 healthCheckRegistry
This property is only available via programmatic configuration or IoC container. This property allows you to specify an instance of a Codahale/Dropwizard HealthCheckRegistry to be used by the pool to report current health information. See the Health Checks wiki page for details. Default: none

🔤 poolName
This property represents a user-defined name for the connection pool and appears mainly in logging and JMX management consoles to identify pools and pool configurations. Default: auto-generated

Infrequently used

initializationFailTimeout
This property controls whether the pool will "fail fast" if the pool cannot be seeded with an initial connection successfully. Any positive number is taken to be the number of milliseconds to attempt to acquire an initial connection; the application thread will be blocked during this period. If a connection cannot be acquired before this timeout occurs, an exception will be thrown. This timeout is applied after the connectionTimeout period. If the value is zero (0), HikariCP will attempt to obtain and validate a connection. If a connection is obtained, but fails validation, an exception will be thrown and the pool not started. However, if a connection cannot be obtained, the pool will start, but later efforts to obtain a connection may fail. A value less than zero will bypass any initial connection attempt, and the pool will start immediately while trying to obtain connections in the background. Consequently, later efforts to obtain a connection may fail. Default: 1

isolateInternalQueries
This property determines whether HikariCP isolates internal pool queries, such as the connection alive test, in their own transaction. Since these are typically read-only queries, it is rarely necessary to encapsulate them in their own transaction. This property only applies if autoCommit is disabled. Default: false

allowPoolSuspension
This property controls whether the pool can be suspended and resumed through JMX. This is useful for certain failover automation scenarios. When the pool is suspended, calls to getConnection() will not timeout and will be held until the pool is resumed. Default: false

readOnly
This property controls whether Connections obtained from the pool are in read-only mode by default. Note some databases do not support the concept of read-only mode, while others provide query optimizations when the Connection is set to read-only. Whether you need this property or not will depend largely on your application and database. Default: false

registerMbeans
This property controls whether or not JMX Management Beans ("MBeans") are registered or not. Default: false

🔤 catalog
This property sets the default catalog for databases that support the concept of catalogs. If this property is not specified, the default catalog defined by the JDBC driver is used. Default: driver default

🔤 connectionInitSql
This property sets a SQL statement that will be executed after every new connection creation before adding it to the pool. If this SQL is not valid or throws an exception, it will be treated as a connection failure and the standard retry logic will be followed. Default: none

🔤 driverClassName
HikariCP will attempt to resolve a driver through the DriverManager based solely on the jdbcUrl, but for some older drivers the driverClassName must also be specified. Omit this property unless you get an obvious error message indicating that the driver was not found. Default: none

🔤 transactionIsolation
This property controls the default transaction isolation level of connections returned from the pool. If this property is not specified, the default transaction isolation level defined by the JDBC driver is used. Only use this property if you have specific isolation requirements that are common for all queries. The value of this property is the constant name from the Connection class such as TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ, etc. Default: driver default

validationTimeout
This property controls the maximum amount of time that a connection will be tested for aliveness. This value must be less than the connectionTimeout. Lowest acceptable validation timeout is 250 ms. Default: 5000

leakDetectionThreshold
This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak. A value of 0 means leak detection is disabled. Lowest acceptable value for enabling leak detection is 2000 (2 seconds). Default: 0

dataSource
This property is only available via programmatic configuration or IoC container. This property allows you to directly set the instance of the DataSource to be wrapped by the pool, rather than having HikariCP construct it via reflection. This can be useful in some dependency injection frameworks. When this property is specified, the dataSourceClassName property and all DataSource-specific properties will be ignored. Default: none

🔤 schema
This property sets the default schema for databases that support the concept of schemas. If this property is not specified, the default schema defined by the JDBC driver is used. Default: driver default

threadFactory
This property is only available via programmatic configuration or IoC container. This property allows you to set the instance of the java.util.concurrent.ThreadFactory that will be used for creating all threads used by the pool. It is needed in some restricted execution environments where threads can only be created through a ThreadFactory provided by the application container. Default: none

scheduledExecutor
This property is only available via programmatic configuration or IoC container. This property allows you to set the instance of the java.util.concurrent.ScheduledExecutorService that will be used for various internally scheduled tasks. If supplying HikariCP with a ScheduledThreadPoolExecutor instance, it is recommended that setRemoveOnCancelPolicy(true) is used. Default: none


Missing Knobs

HikariCP has plenty of "knobs" to turn as you can see above, but comparatively less than some other pools. This is a design philosophy. The HikariCP design aesthetic is Minimalism. In keeping with the simple is better or less is more design philosophy, some configuration axis are intentionally left out.

Statement Cache

Many connection pools, including Apache DBCP, Vibur, c3p0 and others offer PreparedStatement caching. HikariCP does not. Why?

At the connection pool layer PreparedStatements can only be cached per connection. If your application has 250 commonly executed queries and a pool of 20 connections you are asking your database to hold on to 5000 query execution plans -- and similarly the pool must cache this many PreparedStatements and their related graph of objects.

Most major database JDBC drivers already have a Statement cache that can be configured, including PostgreSQL, Oracle, Derby, MySQL, DB2, and many others. JDBC drivers are in a unique position to exploit database specific features, and nearly all of the caching implementations are capable of sharing execution plans across connections. This means that instead of 5000 statements in memory and associated execution plans, your 250 commonly executed queries result in exactly 250 execution plans in the database. Clever implementations do not even retain PreparedStatement objects in memory at the driver-level but instead merely attach new instances to existing plan IDs.

Using a statement cache at the pooling layer is an anti-pattern, and will negatively impact your application performance compared to driver-provided caches.

Log Statement Text / Slow Query Logging

Like Statement caching, most major database vendors support statement logging through properties of their own driver. This includes Oracle, MySQL, Derby, MSSQL, and others. Some even support slow query logging. For those few databases that do not support it, several options are available. We have received a report that p6spy works well, and also note the availability of log4jdbc and jdbcdslog-exp.

Rapid Recovery

Please read the Rapid Recovery Guide for details on how to configure your driver and system for proper recovery from database restart and network partition events.


🚀 Initialization

You can use the HikariConfig class like so1:

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/simpsons");
config.setUsername("bart");
config.setPassword("51mp50n");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

HikariDataSource ds = new HikariDataSource(config);

 1 MySQL-specific example, DO NOT COPY VERBATIM.

or directly instantiate a HikariDataSource like so:

HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl("jdbc:mysql://localhost:3306/simpsons");
ds.setUsername("bart");
ds.setPassword("51mp50n");
...

or property file based:

// Examines both filesystem and classpath for .properties file
HikariConfig config = new HikariConfig("/some/path/hikari.properties");
HikariDataSource ds = new HikariDataSource(config);

Example property file:

dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
dataSource.user=test
dataSource.password=test
dataSource.databaseName=mydb
dataSource.portNumber=5432
dataSource.serverName=localhost

or java.util.Properties based:

Properties props = new Properties();
props.setProperty("dataSourceClassName", "org.postgresql.ds.PGSimpleDataSource");
props.setProperty("dataSource.user", "test");
props.setProperty("dataSource.password", "test");
props.setProperty("dataSource.databaseName", "mydb");
props.put("dataSource.logWriter", new PrintWriter(System.out));

HikariConfig config = new HikariConfig(props);
HikariDataSource ds = new HikariDataSource(config);

There is also a System property available, hikaricp.configurationFile, that can be used to specify the location of a properties file. If you intend to use this option, construct a HikariConfig or HikariDataSource instance using the default constructor and the properties file will be loaded.

Performance Tips

MySQL Performance Tips

Popular DataSource Class Names

We recommended using dataSourceClassName instead of jdbcUrl, but either is acceptable. We'll say that again, either is acceptable.

 Note: Spring Boot auto-configuration users, you need to use jdbcUrl-based configuration.

 The MySQL DataSource is known to be broken with respect to network timeout support. Use jdbcUrl configuration instead.

Here is a list of JDBC DataSource classes for popular databases:

Database Driver DataSource class
Apache Derby Derby org.apache.derby.jdbc.ClientDataSource
Firebird Jaybird org.firebirdsql.ds.FBSimpleDataSource
H2 H2 org.h2.jdbcx.JdbcDataSource
HSQLDB HSQLDB org.hsqldb.jdbc.JDBCDataSource
IBM DB2 IBM JCC com.ibm.db2.jcc.DB2SimpleDataSource
IBM Informix IBM Informix com.informix.jdbcx.IfxDataSource
MS SQL Server Microsoft com.microsoft.sqlserver.jdbc.SQLServerDataSource
MySQL Connector/J com.mysql.jdbc.jdbc2.optional.MysqlDataSource
MariaDB MariaDB org.mariadb.jdbc.MariaDbDataSource
Oracle Oracle oracle.jdbc.pool.OracleDataSource
OrientDB OrientDB com.orientechnologies.orient.jdbc.OrientDataSource
PostgreSQL pgjdbc-ng com.impossibl.postgres.jdbc.PGDataSource
PostgreSQL PostgreSQL org.postgresql.ds.PGSimpleDataSource
SAP MaxDB SAP com.sap.dbtech.jdbc.DriverSapDB
SQLite xerial org.sqlite.SQLiteDataSource
SyBase jConnect com.sybase.jdbc4.jdbc.SybDataSource

Play Framework Plugin

Note Play 2.4 now uses HikariCP by default. A new plugin has come up for the the Play framework; play-hikaricp. If you're using the excellent Play framework, your application deserves HikariCP. Thanks Edulify Team!

Clojure Wrapper

A new Clojure wrapper has been created by tomekw and can be found here.

JRuby Wrapper

A new JRuby wrapper has been created by tomekw and can be found here.


Support 💬

Google discussion group HikariCP here, growing FAQ.

 

Wiki

Don't forget the Wiki for additional information such as:


Requirements

⇒ Java 8+ (Java 6/7 artifacts are in maintenance mode)
⇒ slf4j library

Sponsors

High-performance projects can never have too many tools! We would like to thank the following companies:

Thanks to ej-technologies for their excellent all-in-one profiler, JProfiler.

YourKit supports open source projects with its full-featured Java Profiler. Click the YourKit logo below to learn more.

Contributions

Please perform changes and submit pull requests from the dev branch instead of master. Please set your editor to use spaces instead of tabs, and adhere to the apparent style of the code you are editing. The dev branch is always more "current" than the master if you are looking to live life on the edge.

Comments
  • Connection marked as broken because of SQLSTATE(08003)

    Connection marked as broken because of SQLSTATE(08003)

    PostgreSQL 9.3, Hikari 2.2.5

    I'm getting random exceptions like this:

    17:22:24.117 [qtp1372269468-674] WARN  com.zaxxer.hikari.proxy.ConnectionProxy.checkException() - Connection org.postgresql.jdbc4.Jdbc4Connection@482c822f (HikariPool-39) marked as broken because of SQLSTATE(08003), ErrorCode(0).
    org.postgresql.util.PSQLException: This connection has been closed.
        at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:843)
        at org.postgresql.jdbc2.AbstractJdbc2Connection.setAutoCommit(AbstractJdbc2Connection.java:785)
        at com.zaxxer.hikari.proxy.ConnectionProxy.resetConnectionState(ConnectionProxy.java:164)
        at com.zaxxer.hikari.proxy.ConnectionProxy.close(ConnectionProxy.java:207)
        at com.realestate.backend.scope.DefaultRequestScope$ConnectionFactory.disposeValue(DefaultRequestScope.java:200)
        at com.realestate.backend.scope.DefaultRequestScope$ConnectionFactory.disposeValue(DefaultRequestScope.java:147)
        at org.bitbucket.cowwoc.pouch.LazyFactory.close(LazyFactory.java:59)
        at com.realestate.backend.scope.DefaultRequestScope.close(DefaultRequestScope.java:143)
        at com.realestate.backend.jersey.PouchBinder$RequestFactory.dispose(PouchBinder.java:50)
        at com.realestate.backend.jersey.PouchBinder$RequestFactory.dispose(PouchBinder.java:23)
        at org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:114)
        at org.jvnet.hk2.internal.SystemDescriptor.dispose(SystemDescriptor.java:516)
        at org.glassfish.jersey.process.internal.RequestScope$Instance.remove(RequestScope.java:512)
        at org.glassfish.jersey.process.internal.RequestScope$Instance.release(RequestScope.java:529)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:299)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1030)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:534)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:482)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:419)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:497)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
        at java.lang.Thread.run(Thread.java:745)
    17:22:24.121 [qtp1372269468-674] WARN  org.eclipse.jetty.servlet.ServletHandler.doHandle() - 
    javax.servlet.ServletException: A MultiException has 1 exceptions.  They are:
    1. java.lang.IllegalStateException: Attempt to remove an object from the bag that was not borrowed or reserved
    
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:393)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:534)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:482)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:419)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:497)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: org.glassfish.hk2.api.MultiException: A MultiException has 1 exceptions.  They are:
    1. java.lang.IllegalStateException: Attempt to remove an object from the bag that was not borrowed or reserved
    
        at org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:121)
        at org.jvnet.hk2.internal.SystemDescriptor.dispose(SystemDescriptor.java:516)
        at org.glassfish.jersey.process.internal.RequestScope$Instance.remove(RequestScope.java:512)
        at org.glassfish.jersey.process.internal.RequestScope$Instance.release(RequestScope.java:529)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:299)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1030)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
        ... 22 common frames omitted
    Caused by: java.lang.IllegalStateException: Attempt to remove an object from the bag that was not borrowed or reserved
        at com.zaxxer.hikari.util.ConcurrentBag.remove(ConcurrentBag.java:206)
        at com.zaxxer.hikari.pool.HikariPool.closeConnection(HikariPool.java:378)
        at com.zaxxer.hikari.pool.HikariPool.releaseConnection(HikariPool.java:220)
        at com.zaxxer.hikari.proxy.ConnectionProxy.close(ConnectionProxy.java:216)
        at com.realestate.backend.scope.DefaultRequestScope$ConnectionFactory.disposeValue(DefaultRequestScope.java:200)
        at com.realestate.backend.scope.DefaultRequestScope$ConnectionFactory.disposeValue(DefaultRequestScope.java:147)
        at org.bitbucket.cowwoc.pouch.LazyFactory.close(LazyFactory.java:59)
        at com.realestate.backend.scope.DefaultRequestScope.close(DefaultRequestScope.java:143)
        at com.realestate.backend.jersey.PouchBinder$RequestFactory.dispose(PouchBinder.java:50)
        at com.realestate.backend.jersey.PouchBinder$RequestFactory.dispose(PouchBinder.java:23)
        at org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:114)
        ... 29 common frames omitted
    

    With the default value of log_statement the only log I see is:

    2014-11-17 17:14:56 EST 546a735e.31a0 ERROR:  could not serialize access due to concurrent update
    2014-11-17 17:14:56 EST 546a735e.31a0 STATEMENT:  update "user"
        set email = $1, password = $2, name = $3, version = $4, last_modified = $5
        where "user".id = $6
    

    but I don't think is related. I tried increasing the level of log_statement but got a lot of noise.

    Any ideas on how to debug this further? Does the stack-trace give you any clues? Is there a specific text pattern I should scan for with log_statement = 'all'?

    bug 
    opened by cowwoc 70
  • Failed to get/set network timeout for connection.

    Failed to get/set network timeout for connection.

    Using latest (9.4.1208) PostgreSQL JDBC driver and Java 8:

    WARN 15:55:44,723 lBase - HikariPool-0 - Failed to get/set network timeout for connection. (Method org.postgresql.jdbc.PgConnection.getNetworkTimeout() is not yet implemented.)

    Is it falling back to a safe value if such call fails? Maybe modifying that message to state something like:

    Falling back to X value or using X default value instead.

    Would be great not to panic the user?

    opened by guidomedina 47
  • HikariPool.getConnection freezes in certain circumstances

    HikariPool.getConnection freezes in certain circumstances

    Hi,

    I have been happily using Hikari for more than a year. Yesterday, I ran into a strange problem. My connection pool is getting initialized fine. But when Hibernate tries to get a connection via dataSource.getConnection, it freezes indefinitely. I have tried to make the connectionTimeout parameter very large to see if this was a resource issue. But the getConnection times out regardless of the timeout period.

    Another interesting thing is that the the same code is working perfectly fine on one of the two identical machines in terms of software. The only significant difference between the two machines is that one has only one core (where it is not working) and the other has 8 cores (where it is working).

    The various versions of libraries/tools that I am using are:

    1. Play Framework 2.4.2 (with hikari has the default pool)
    2. Hibernate 5 (recently upgraded from 4.3.8)
    3. Postgres 9.4
    4. Ubuntu 14.04
    5. Oracle JDK 1.8.0_45

    This is my config in play:

      logSql=true
      dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
      connectionTestQuery="SELECT 1"
      initializationFailFast=true
      maximumPoolSize=10
      autoCommit=false
      dataSource {
        user=xxxxxx
        password=xxxxxx
        databaseName=xxxxxxx
        serverName=localhost
      }
    

    I took the thread dump using jstack while hibernate was blocked, the relevant parts of which look like this:

     "ForkJoinPool-1-worker-1" #46 daemon prio=5 os_prio=0 tid=0x00007f0945f68000 nid=0xd29 waiting on condition [0x00007f093444e000]
    java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000d1727b08> (a com.zaxxer.hikari.util.QueuedSequenceSynchronizer$Synchronizer)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
        at java.util.concurrent.locks.AbstractQueuedLongSynchronizer.doAcquireSharedNanos(AbstractQueuedLongSynchronizer.java:815)
        at java.util.concurrent.locks.AbstractQueuedLongSynchronizer.tryAcquireSharedNanos(AbstractQueuedLongSynchronizer.java:1106)
        at com.zaxxer.hikari.util.QueuedSequenceSynchronizer.waitUntilSequenceExceeded(QueuedSequenceSynchronizer.java:92)
        at com.zaxxer.hikari.util.ConcurrentBag.borrow(ConcurrentBag.java:159)
        at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:182)
        at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:163)
        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:85)
        at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
       at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    

    And here's the debug-log while hibernate seems to be stuck:

    [info] c.z.h.HikariDataSource - HikariPool-0 - is starting.
    [debug] c.z.h.p.PoolElf - HikariPool-0 - Connection.setNetworkTimeout() is not supported (org.postgresql.jdbc4.Jdbc4Connection.getNetworkTimeout()I)
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@26ccc54a
    [debug] c.z.h.p.PoolElf - HikariPool-0 - Reset (autoCommit) on connection org.postgresql.jdbc4.Jdbc4Connection@26ccc54a
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@319e194b
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@3f59e108
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@3b66723b
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@7e64eb33
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@3ff1e1f5
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@4fd016a2
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@47af42c9
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@1e4b147c
    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@2e05a009
    [debug] c.z.h.p.HikariPool - After fill pool HikariPool-0 stats (total=10, active=0, idle=10, waiting=0)
    [debug] c.z.h.p.PoolElf - HikariPool-0 - Reset (autoCommit) on connection org.postgresql.jdbc4.Jdbc4Connection@319e194b
    [debug] c.z.h.p.PoolElf - HikariPool-0 - Reset (autoCommit) on connection org.postgresql.jdbc4.Jdbc4Connection@26ccc54a
    [debug] c.z.h.p.PoolElf - HikariPool-0 - Statement.setQueryTimeout() is not supported (Method org.postgresql.jdbc4.Jdbc4Statement.setQueryTimeout(int) is not yet implemented.)
    HikariConnectionProxy@360951608 wrapping org.postgresql.jdbc4.Jdbc4Connection@26ccc54a
    [debug] c.z.h.p.HikariPool - Before cleanup pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - After cleanup  pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - Before cleanup pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - After cleanup  pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - Before cleanup pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - After cleanup  pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - Before cleanup pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - After cleanup  pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - Before cleanup pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - After cleanup  pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - Before cleanup pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    [debug] c.z.h.p.HikariPool - After cleanup  pool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)
    

    The surprising thing is that when I create a pool using the same config in the scala console (in the same project using sbt console) and call the getConnection, it seems to work fine.

    I am not yet sure what's the problem. Looking into it. Looking at the thread dump, it looks like it could be related to concurrency since the thread seems to be getting stuck at ConcurrentBag.borrow.

    question 
    opened by Bhashit 47
  • Idle connections not getting closed

    Idle connections not getting closed

    Hi,

    We have recently started using HikariCP for pooling our database (replacing DBCP) connections. We have noticed that HikariCP is not closing some of the idle connections to database making the database close the connection after 8 hours (which is the mysql wait_timeout). Whenever the pool tries to use this connection, we get an error that looks something like this:

    * The last packet successfully received from the server was 3,321,958,752 milliseconds ago. The last packet sent successfully to the server was 3,321,958,756 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 3,321,958,752 milliseconds ago.**

    From documentation of HikariCP, I see that the default idleTimeout is around 10 minutes and connections will be automatically closed if older than that time.

    We have taken thread and heap dumps of the Java process during this time and found that there is an object of type PoolBagEntry containing a connection where isClosed = false though the FD it is holding is no longer in use (from lsof on that host) indicating that the TCP connection has been closed but the pool still considers the connection open. This is happening quite frequently, at least 1 connection from the pool behaving this way (our pool size is 10). Do let us know if something needs to be changed in our configuration or the way we use.

    Please find below details on how we are using and version information.
    Spring Configuration: ${jdbc_url} ${jdbc_username} ${jdbc_password} true 250 2048 true utf8 true

    Mysql Server Version: 5.5 Mysql JDBC Library Version: mysql-connector-java-5.1.34.jar HikariCP Library Version: HikariCP-java6-2.3.2.jar Java Version: 1.7.0_60-b19

    question 
    opened by mpoornima 47
  • NullPointerException in utility thread, only appearing on console

    NullPointerException in utility thread, only appearing on console

    I am creating this for the one from the google group https://groups.google.com/forum/#!topic/hikari-cp/RgS7J0Xs05U

    quote:

    I'm getting this funny exceptions. It only appears in my console, not on my logs where HikariCP messages appear. It seems to appear every few minutes, maybe after inactivity.

    end quote

    The stacktraces seem to appear without anything happening in particular, while the various dev/testing web apps where HikariCP is used still function as normal so far but the connection may possible fail in the middle of a long series of database operations when this happens. I am not really sure.

    Exception in thread "HikariCP utility thread (pool HikariPool-0)" java.lang.NullPointerException at com.mysql.jdbc.MysqlIO.setSocketTimeout(MysqlIO.java:4890) at com.mysql.jdbc.ConnectionImpl$12.run(ConnectionImpl.java:5540) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Exception in thread "HikariCP utility thread (pool HikariPool-0)" java.lang.NullPointerException at com.mysql.jdbc.MysqlIO.setSocketTimeout(MysqlIO.java:4890) at com.mysql.jdbc.ConnectionImpl$12.run(ConnectionImpl.java:5540) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Exception in thread "HikariCP utility thread (pool HikariPool-0)" java.lang.NullPointerException at com.mysql.jdbc.MysqlIO.setSocketTimeout(MysqlIO.java:4890) at com.mysql.jdbc.ConnectionImpl$12.run(ConnectionImpl.java:5540) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

    bug 
    opened by ghost 46
  • URGENT: Unusual system clock change detected, soft-evicting connections from pool.

    URGENT: Unusual system clock change detected, soft-evicting connections from pool.

    Brett,

    I saw a ton of connections from a particular host last night...

    dgcs=# select distinct usename, application_name, client_addr, count(*) from pg_stat_activity where client_addr = '10.101.152.33' group by  usename, application_name, client_addr order by client_addr, usename;
         usename      | application_name |  client_addr  | count 
    ------------------+------------------+---------------+-------
     analytics_rw     |                  | 10.101.152.33 |   289
     catalog_rw       |                  | 10.101.152.33 |   192
     dgwatch_rw       |                  | 10.101.152.33 |    40
     member_rw        |                  | 10.101.152.33 |   508
     wps_processor_rw |                  | 10.101.152.33 |   200
    (5 rows)
    

    This morning, come to find the following in the log files every hour or so...

    2016-01-25 21:09:15,498 WARN  [a3808e51-ff45-4d72-b5de-7efdd973ec27] [Hikari housekeeper (pool 1-MemberConnectionPool)] [pool.HikariPool] - 1-MemberConnectionPool - Unusual system clock change detected, soft-evicting connections from pool.
    2016-01-25 21:09:17,948 WARN  [a3808e51-ff45-4d72-b5de-7efdd973ec27] [Hikari housekeeper (pool 2-AnalyticsConnectionPool)] [pool.HikariPool] - 2-AnalyticsConnectionPool - Unusual system clock change detected, soft-evicting connections from pool.
    2016-01-25 22:09:44,837 WARN  [a3808e51-ff45-4d72-b5de-7efdd973ec27] [Hikari housekeeper (pool 1-MemberConnectionPool)] [pool.HikariPool] - 1-MemberConnectionPool - Unusual system clock change detected, soft-evicting connections from pool.
    2016-01-25 22:09:47,267 WARN  [a3808e51-ff45-4d72-b5de-7efdd973ec27] [Hikari housekeeper (pool 2-AnalyticsConnectionPool)] [pool.HikariPool] - 2-AnalyticsConnectionPool - Unusual system clock change detected, soft-evicting connections from pool.
    2016-01-25 23:10:45,845 WARN  [a3808e51-ff45-4d72-b5de-7efdd973ec27] [Hikari housekeeper (pool 1-MemberConnectionPool)] [pool.HikariPool] - 1-MemberConnectionPool - Unusual system clock change detected, soft-evicting connections from pool.
    2016-01-25 23:10:48,285 WARN  [a3808e51-ff45-4d72-b5de-7efdd973ec27] [Hikari housekeeper (pool 2-AnalyticsConnectionPool)] [pool.HikariPool] - 2-AnalyticsConnectionPool - Unusual system clock change detected, soft-evicting connections from pool.
    

    These are my configs:

    <maxLifetime>1800000</maxLifetime>
    <idleTimeout>600000</idleTimeout>
    <mininumPoolSize>5</mininumPoolSize>
    <maximumPoolSize>100</maximumPoolSize>
    <connectionTimeout>30000</connectionTimeout>
    <validationTimeout>5000</validationTimeout>
    

    What is causing this? And, what exactly is soft-evicting? Does that fail to close the original connections?

    Thanks!

    question 
    opened by victropolis 43
  • Very slow calling getConnection

    Very slow calling getConnection

    This is a shot in the dark. We recently (2 weeks ago) switched from the default pooling provider in Play 2.3 (BoneCP) to HikariCP.

    Earlier today we had a huge spike in the application, and analysis revealed that getConnection() of HikariCP was taking ~7 seconds per invocation.

    screen shot 2014-12-09 at 3 05 09 pm

    Any ideas on what might cause this? Analysis of the database shows the database running normal up to this point, and then once the spike occurred, the load average (and queries) went DOWN during this spike in behavior as no connections were being made, and thus no operations were being done.

    [ Due to network configuration with the firewall, we have a very short TTL for connections of 2 mins ]

    bug 
    opened by nateww 43
  • java.sql.SQLException: Timeout of 30000ms encountered waiting for connection

    java.sql.SQLException: Timeout of 30000ms encountered waiting for connection

    I am testing a little udp server I created. In my test environment, I have a udp client that runs every 30 seconds and it sends a packet to the server. The server decodes packet and inserts data into postgresql database. There is absolutely no load on this. Yet, sometimes I get this error:

    java.sql.SQLException: Timeout of 30000ms encountered waiting for connection

    resulting from this code:

        conn = dbPool.getConnection();
        stmt = conn.createStatement();
        status = stmt.executeUpdate(sql);
    

    dbPool is simply an abstraction of HikariCp:

        HikariConfig config = new HikariConfig();  
    config.setMaximumPoolSize(50);
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    config.addDataSourceProperty("serverName", host);
    config.addDataSourceProperty("databaseName", database);
    config.addDataSourceProperty("portNumber", "5432");
    config.addDataSourceProperty("user", username);
    config.addDataSourceProperty("password", password);
        ds = new HikariDataSource(config);
    
    public Connection getConnection()  throws SQLException  
    {  
        return ds.getConnection();  
    }
    

    Why am I getting a connection timeout with hikaricp within this light test environment with only one request every 30 seconds?

    bug 
    opened by JohnMerlino1 42
  • Problem with 2.4.2 and 2.4.3

    Problem with 2.4.2 and 2.4.3

    On startup, we're seeing:

    org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) ~[hibernate-core.jar:5.0.3.Final]
            ....
    Caused by: org.hibernate.HibernateException: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Exception during pool initialization: Live - Connection is not available, request timed out after 30000ms.
            at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:63) ~[hibernate-hikaricp.jar:5.0.3.Final]
            at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) ~[hibernate-core.jar:5.0.3.Final]
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234) ~[hibernate-core.jar:5.0.3.Final]
    

    On the db side we can see that connections are indeed being opened.

    To make this even stranger, we're only running into this on our production server. We have a duplicate test server, and it seems just fine there. Reverting to 2.4.1 made this issue go away.

    Any ideas on what the problem might be?

    question 
    opened by markwoon 40
  • Randomly HikariPool pool becomes zero and HikariCP is not renewing/creating new connections

    Randomly HikariPool pool becomes zero and HikariCP is not renewing/creating new connections

    We are facing a weird error in our production server. We are keep getting HikariPool-1 - Connection is not available, request timed out after 30002ms. error after some hours. If we restart the application the problem solved temporarily but it will occur at least one time each day.

    Here is the some environment details:

    Environment

    HikariCP version: 2.4.11 (HikariCP-java7)
    JDK version     : 1.7.0_80
    Database        : Oracle
    Driver version  : ojdbc7
    

    2018-10-15 12:07:39.578[main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:

    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension.............false
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit......................true
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - catalog.........................none
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql...............none
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery.............none
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout...............30000
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource......................none
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName.............none
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................none
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties............{password=<masked>}
    2018-10-15 12:07:39.580[main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................."oracle.jdbc.OracleDriver"
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties...........{}
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry.............none
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout.....................600000
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailFast..........true
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout.......1
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - jdbc4ConnectionTest.............false
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl........................."jdbc:oracle:thin:@db.com:1521:orcl"
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........0
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime.....................1800000
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize.................150
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry..................none
    2018-10-15 12:07:39.581[main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory...........none
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle.....................50
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - password........................<masked>
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - poolName........................"HikariPool-1"
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly........................false
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans..................false
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor...............none
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutorService........internal
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory...................internal
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation............default
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - username........................"user"
    2018-10-15 12:07:39.582[main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout...............5000
    2018-10-15 12:07:40.001[main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection oracle.jdbc.driver.T4CConnection@4ef130
    

    Here is stack trace from application log.

    2018-10-11 10:59:13.457.XNIO-3 task-2> DEBUG - HikariPool-1 - Timeout failure stats (total=0, active=0, idle=0, waiting=171)
    2018-10-11 10:59:13.457.XNIO-3 task-2> WARN - SQL Error: 0, SQLState: null 
    2018-10-11 10:59:13.457.XNIO-3 task-2> ERROR - HikariPool-1 - Connection is not available, request timed out after 30002ms. 
    2018-10-11 10:59:13.458.XNIO-3 task-2> ERROR - UT005023: Exception handling request to /mobile-platform/api/login 
    org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
    	at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:431)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:447)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    	at com.sun.proxy.$Proxy187.checkWalletStatus(Unknown Source)
    	at a.b.c.d(Application.java:68)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    	at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
    	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
    	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
    	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
    	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1700)
    	at org.hibernate.jpa.internal.TransactionImpl.begin(TransactionImpl.java:48)
    	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:189)
    	at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:380)
    	... 51 common frames omitted
    Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
    	at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:48)
    	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
    	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
    	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:90)
    	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:112)
    	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getConnectionForTransactionManagement(LogicalConnectionManagedImpl.java:230)
    	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.begin(LogicalConnectionManagedImpl.java:237)
    	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.begin(JdbcResourceLocalTransactionCoordinatorImpl.java:214)
    	at org.hibernate.engine.transaction.internal.TransactionImpl.begin(TransactionImpl.java:52)
    	at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1512)
    	at org.hibernate.jpa.internal.TransactionImpl.begin(TransactionImpl.java:45)
    	... 53 common frames omitted
    Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30002ms.
    	at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:583)
    	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:186)
    	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:145)
    	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
    	at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
    	at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:386)
    	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:87)
    	... 60 common frames omitted
    
    

    I do not understand why is not Hikaricp creating new connection even though total pool size is 0. Any help would be appreciated.

    Thanks.

    opened by discreet2 36
  • HikariPool-1 - Connection is not available, request timed out after 30096ms.

    HikariPool-1 - Connection is not available, request timed out after 30096ms.

    Environment

    HikariCP version: 2.7.8
    JDK version     : 1.8.0_111
    Database        : MySQL|
    

    Hey, since long time I have big problem with my database, when I'm doing something I got this: (HikariPool-1 - Connection is not available, request timed out after 30000ms. | ) [09:26:26] [Craft Scheduler Thread - 2/WARN]: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms. [09:26:26] [Craft Scheduler Thread - 2/WARN]: at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:667) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:183) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:148) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at xyz.yooniks.something.subpackage.SomeCommand$1.run(SomeCommand.java:74) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at org.github.paperspigot.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:23) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [09:26:26] [Craft Scheduler Thread - 2/WARN]: at java.lang.Thread.run(Thread.java:748) How can I fix that?

    not-a-bug 
    opened by yooniks 35
  • poolName from HikariConfig is not used for checkFailFast

    poolName from HikariConfig is not used for checkFailFast

    I define a hikari datasource like this in my springboot (2.7.5) app:

    @Bean(name = "historyDbDataSource", destroyMethod = "close")
        DataSource historyDbDataSource(final HistoryJdbcProperties properties) {
          final HikariConfig hikariConfig = new HikariConfig();
          hikariConfig.setDataSource(
              DataSourceBuilder
                  .create()
                  .url(properties.getUrl())
                  .username(properties.getUsername())
                  .password(properties.getPassword())
                  .driverClassName(properties.getDriver())
                  .build());
          hikariConfig.setMaximumPoolSize(properties.getMaxPoolSize());
          hikariConfig.setPoolName("history-db-pool");
          final ScheduledThreadPoolExecutor executor = newScheduledThreadPoolExecutor(1, "history-db-pool housekeeper");
          executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
          executor.setRemoveOnCancelPolicy(true);
          hikariConfig.setScheduledExecutor(executor);
          // hikariConfig.setInitializationFailTimeout(-1);
          LOGGER.info("Create pooled hikari datasource for history-db with max-pool-size '{}'", properties.getMaxPoolSize());
          return new HikariDataSource(hikariConfig);
        }
    

    The running debug from hikari show me (right at the beginning) that a generated pool name is used (maybe only temp.) ...

    image

    opened by ahoehma 0
  • ClassNotFoundException Error

    ClassNotFoundException Error

    I tried using Hikari in my spigot pluggin. I get the following error on startup:

    java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
    	at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:106) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:322) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:112) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:93) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at de.dark.coinapi.CoinAPI.createTables(CoinAPI.java:129) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at de.dark.coinapi.CoinAPI.onEnable(CoinAPI.java:58) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:371) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:548) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:611) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:525) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:641) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:427) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:343) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1116) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:310) ~[purpur-1.19.2.jar:git-Purpur-1858]
    	at java.lang.Thread.run(Thread.java:833) ~[?:?]
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
    	at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:179) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    	at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:126) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    	at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:93) ~[CoinAPI-1.0-SNAPSHOT.jar:?]
    	... 17 more
    

    HikariCP Verison: 5.0.1 Java Version: 17

    opened by Colors45 0
  • char[] password for Driver-based configurations

    char[] password for Driver-based configurations

    I'm pretty sure this is not a bug but a feature request but here it goes:

    I just updated the JDBC driver I was using and the connexion pool configuration started failling. The problem is that my JDBC driver's setPassword method now has this signature:

    void com.ibm.as400.access.AS400JDBCDataSource.setPassword(char[])

    Notice "not a String."

    In the PropertyElf.setProperty method, there is an if to branch to the various types of parameters (int, long, short, boolean, String). char[] could be added to the list. :)

    There is a discussion on stackoverflow on why char[] is better than String for password: https://stackoverflow.com/questions/8881291/why-is-char-preferred-over-string-for-passwords

    opened by cquezel 0
  • Diagnosing intermittent connection failures

    Diagnosing intermittent connection failures

    I'm having a very bizarre intermittent failure issue, and I have run out of ideas for dealing with it. I am running 6 applications in an AWS EC2 instance, each connecting to the same RDS aurora mysql instance. Several times a day the same one will experience issues connecting to the database. The others will go on without problems. This problem seems to be related to the load on the application, but it's not straightforward. I have confirmed that the vm is time synced using chrony. Here's my connection parameters:

    config.setDriverClassName("software.aws.rds.jdbc.mysql.Driver"); config.setJdbcUrl("jdbc:mysql://database:3306/schema?allowMultiQueries=true"); config.setUsername(dbUsername); config.setPassword(dbPassword); config.setConnectionTimeout(5000); config.setLeakDetectionThreshold(30000); config.setMinimumIdle(5); config.setKeepaliveTime(30000); config.setIdleTimeout(600000); config.setMaxLifetime(1800000); config.setMaximumPoolSize(30); config.setTransactionIsolation("TRANSACTION_READ_COMMITTED"); config.addDataSourceProperty("prepStmtCacheSize", "500"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("cachePrepStmts", true); config.addDataSourceProperty("useServerPrepStmts", true);

    This then gets wrapped into a Spring TransactionAwareDataSourceProxy, then into a Spring PersistenceUnitManager.

    Setting the Hikari log to trace doesn't give many clues, https://pastebin.com/hknN8EXn At the beginning everything is fine, then Hikari starts adding connections. Eventually Hikari starts complaining about leaks and timeouts getting connections, but I don't know if that's a symptom of connection issues. I can't think of any process of ours that could cause us leak all 30 of our max connections over the span of 15 seconds.

    Any assistance in dealing with this issue would be appreciated. Right now we've resorted to clustering the application and just restarting the failing one, but that's not a great solution long term.

    Thank you

    opened by AndrewBarton 0
  • Identify the threads holding the connection

    Identify the threads holding the connection

    @brettwooldridge My application has the following Hikari configuration:

    maximumPoolSize=20
    minimumIdle = 20
    connectionTimeout = 500
    maxLifetime = 1800000
    

    Recently I started to see connection timeout errors : Connection is not available, request timed out after 500ms . I already verified that there is no connection leak. After some trial and error, I increased the pool size to 22 and that reduced the number of errors. But I still see some now and then.

    To investigate it further, I now create a thread dump whenever this exception is thrown. However, it would be great if I could also identify the threads that hold the connection at that time.

    Is it possible to log the thread name/ids that are holding the connection at any moment? I see that when I enable leakDetection, it logs the thread name: Connection leak detection triggered for xxxx on thread xxxx, stack trace follows . But I did not find a way to get this information without triggering leakDetection .

    opened by SharmaAyushi 0
  • Connections dropped when Hikari used with RDSProxy

    Connections dropped when Hikari used with RDSProxy

    We are using a set of microservices built in Java that run on ECS Fargate. They connect to an AWS RDS PostgresDB. Each service uses a Hikari connection pool with the following settings: maxPoolSize 10, maxLifetimeMs 25 mins, minIdle 0, and idleTimeoutMs 10 seconds.

    This setup worked well, but we had to introduce RDSProxy to run one of the microservices in Lambda. Now our microservices reach RDS through Hikari and RDSProxy: Hikari → RDSProxy → RDS. Note that RDSProxy is configured with IdleClientTimeout set to 30 mins.

    With the new setup, we have started receiving the following error:

    HikariPool-1 - Failed to validate connection org. PostgreSQL.jdbc.PgConnection@16913c10 (This connection has been closed.). Possibly consider using a shorter maxLifetime value.
    

    While this error is rare at about once a month, it suggests that connections are getting closed. Since some microservices in our setup are on the critical path, we can’t afford to drop connections.

    We expect active connections not to get dropped, and based on our configured settings, we expect no idle connections in Hikari - at least after 10 seconds. Therefore, we can't identify why these connections are being dropped.

    Can you advise on configuring Hikari with RDSProxy so that connections don't get dropped?

    opened by farazhv 2
Owner
Brett Wooldridge
Vice President and Lead Architect of Software Development. Father of an angel who fell to Earth and somehow into my life.
Brett Wooldridge
FlexyPool adds metrics and failover strategies to a given Connection Pool, allowing it to resize on demand.

Introduction The FlexyPool library adds metrics and flexible strategies to a given Connection Pool, allowing it to resize on demand. This is very hand

Vlad Mihalcea 970 Jan 1, 2023
🔥 强大的动态线程池,附带监控线程池功能(没有依赖任何中间件)。Powerful dynamic thread pool, does not rely on any middleware, with monitoring thread pool function.

ThreadPool, so easy. 动态线程池监控,主意来源于美团技术公众号 点击查看美团线程池文章 看了文章后深受感触,再加上最近线上线程池的不可控以及不可逆等问题,想做出一个兼容性、功能性、易上手等特性集于一身的的开源项目。目标还是要有的,虽然过程可能会艰辛 目前这个项目是由作者独立开发,

龙台 3.4k Jan 3, 2023
🔥 强大的动态线程池,附带监控线程池功能(没有依赖任何中间件)。Powerful dynamic thread pool, does not rely on any middleware, with monitoring thread pool function.

?? 动态线程池系统,包含 Server 端及 SpringBoot Client 端需引入的 Starter. 动态线程池监控,主意来源于美团技术公众号 点击查看美团线程池文章 看了文章后深受感触,再加上最近线上线程池的不可控以及不可逆等问题,想做出一个 兼容性、功能性、易上手等特性 集于一身的的

龙台 3.4k Jan 3, 2023
SPRING MySQL Database Connection using JDBC STEPS

SPRING-MySQL-Database-Connection-using-JDBC-STEPS SPRING MySQL Database Connection using JDBC STEPS Step1: Create maven project Group id: com.cdac Art

Dnyaneshwar Madhewad 1 Jan 27, 2022
JDBC driver for ClickHouse

This is a basic and restricted implementation of jdbc driver for ClickHouse. It has support of a minimal subset of features to be usable.

ClickHouse 1.1k Jan 1, 2023
Multi-DBMS SQL Benchmarking Framework via JDBC

BenchBase BenchBase (formerly OLTPBench) is a Multi-DBMS SQL Benchmarking Framework via JDBC. Table of Contents Quickstart Description Usage Guide Con

CMU Database Group 213 Dec 29, 2022
Provides many useful CRUD, Pagination, Sorting operations with Thread-safe Singleton support through the native JDBC API.

BangMapleJDBCRepository Inspired by the JpaRepository of Spring framework which also provides many capabilities for the CRUD, Pagination and Sorting o

Ngô Nguyên Bằng 5 Apr 7, 2022
Core ORMLite functionality that provides a lite Java ORM in conjunction with ormlite-jdbc or ormlite-android

ORMLite Core This package provides the core functionality for the JDBC and Android packages. Users that are connecting to SQL databases via JDBC shoul

Gray 547 Dec 25, 2022
Amazon AppFlow Custom JDBC Connector example

Amazon AppFlow Custom JDBC Connector example This project contains source code and supporting files that implements Amazon Custom Connector SDK and re

AWS Samples 6 Oct 26, 2022
Online Quiz system - JDBC, JSP

Online-Quiz-System-in-Java Online Quiz system - JDBC, JSP Java Project based on JDBC, JSP, Java Servlet and Server Deployment Project Aim Develop web

Muhammad Asad 6 Oct 14, 2022
Hi, Spring fans! In this installment, we'll look at how to build tenancy-aware JDBC applications

Multitenant JDBC You'll need to spin up two separate PostgreSQL instances. Put this script into a file called postgres.sh: #!/usr/bin/env bash NAME=${

Spring Tips 19 Nov 7, 2022
esProc SPL is a scripting language for data processing, with well-designed rich library functions and powerful syntax, which can be executed in a Java program through JDBC interface and computing independently.

esProc esProc is the unique name for esProc SPL package. esProc SPL is an open-source programming language for data processing, which can perform comp

null 990 Dec 27, 2022
A JDBC driver for Cloudflare's D1 product, compatible with Jetbrains tools.

D1 JDBC Driver A JDBC driver for Cloudflare's D1 Database product! JDBC is the technology that drives popular database tools such as Jetbrains' databa

Isaac McFadyen 21 Dec 9, 2022
Apache Druid: a high performance real-time analytics database.

Website | Documentation | Developer Mailing List | User Mailing List | Slack | Twitter | Download Apache Druid Druid is a high performance real-time a

The Apache Software Foundation 12.3k Jan 1, 2023
Microstream - High-Performance Java-Native-Persistence

Microstream - High-Performance Java-Native-Persistence. Store and load any Java Object Graph or Subgraphs partially, Relieved of Heavy-weight JPA. Microsecond Response Time. Ultra-High Throughput. Minimum of Latencies. Create Ultra-Fast In-Memory Database Applications & Microservices.

MicroStream 410 Dec 28, 2022
Replicate your Key Value Store across your network, with consistency, persistance and performance.

Chronicle Map Version Overview Chronicle Map is a super-fast, in-memory, non-blocking, key-value store, designed for low-latency, and/or multi-process

Chronicle Software : Open Source 2.5k Dec 29, 2022
Vibur DBCP - concurrent and dynamic JDBC connection pool

Vibur DBCP is concurrent, fast, and fully-featured JDBC connection pool, which provides advanced performance monitoring capabilities, including slow S

Vibur 94 Apr 20, 2022
FlexyPool adds metrics and failover strategies to a given Connection Pool, allowing it to resize on demand.

Introduction The FlexyPool library adds metrics and flexible strategies to a given Connection Pool, allowing it to resize on demand. This is very hand

Vlad Mihalcea 970 Jan 1, 2023
Connection Pool Test Setup

Connection Pool Test Setup Setup to test the behavior of http connection pools with the following setup server-apache apache server with proxy-pass to

Johannes Wendig 1 Jan 21, 2022
🔥 强大的动态线程池,附带监控线程池功能(没有依赖任何中间件)。Powerful dynamic thread pool, does not rely on any middleware, with monitoring thread pool function.

ThreadPool, so easy. 动态线程池监控,主意来源于美团技术公众号 点击查看美团线程池文章 看了文章后深受感触,再加上最近线上线程池的不可控以及不可逆等问题,想做出一个兼容性、功能性、易上手等特性集于一身的的开源项目。目标还是要有的,虽然过程可能会艰辛 目前这个项目是由作者独立开发,

龙台 3.4k Jan 3, 2023