Coder Social home page Coder Social logo

hikaricp's Introduction

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 11+ maven artifact:

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

Java 8 maven artifact (maintenance mode):

<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 noticeable 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
Google Spanner Spanner com.google.cloud.spanner.jdbc.JdbcDriver
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.

hikaricp's People

Contributors

ams2990 avatar ash2k avatar brettwooldridge avatar cal101 avatar cenkakin avatar checketts avatar cowwoc avatar elfolink avatar goekay avatar gsmet avatar jaredstehler avatar johnou avatar kschmit90 avatar lburgazzoli avatar lfbayer avatar matsumana avatar monichev avatar msteiger avatar nitincchauhan avatar pascalschumacher avatar quaff avatar schlosna avatar shredder121 avatar sjaenick avatar sullis avatar swaldman avatar tedeling avatar udayshnk avatar wvuong avatar xkr47 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hikaricp's Issues

Small suggestion

Hi,

I'm the author of BoneCP. I'm delighted at finding your project - some interesting ideas out there! Thank you for taking the time to document your techniques. Do you accept contributions? :-)

Might I suggest adding units to your config methods eg InSeconds etc, before I did this, forums were filled with people getting the units wrong, they disappeared when I made the API more explicit. In other words try to avoid the mistakes I made in my initial versions :-)

Allow data source properties to be set directly in HikariConfig

Currently there are two ways of configuring data source properties:

  • method addDataSourceProperty(String propertyName, Object value)
  • constructor HikariConfig(String propertyFileName)

I'm configuring HikariCP with spring xml configuration and I need to set datasource properties (url, user, password).

I can't call the method addDataSourceProperty from the xml configuration and I would need a real file for the constructor. Could you add possibility to set Properties directly, e.g. method

setDriverProperties(Properties properties)

or constructor

HikariConfig(Properties properties)

Suggestions for Spring + JPA as persistence.xml?

Stumbled on this interesting tool today. Do you have guidance for expressing the appcontext config instead as a persistence.xml - following your MySQL example using JPA (2.x), Hibernate (4.x)?

UTF-8 character encoding

I can't seem to be able to get data encoded in UTF-8 (cyrilic , arabic alphabets etc) from my MySQL database. Everything else works correctly and as expected.
Without HikariCP (no connection pooling) I used "useUnicode=true&characterEncoding=UTF-8" as a property for my connection and it worked.
With HikariCP i tried something similar for the configuration:
config.addDataSourceProperty("url", "jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=UTF-8");
I also tried using the following:
config.addDataSourceProperty("characterEncoding",Charsets.UTF_8.name());
config.addDataSourceProperty("useUnicode","true");
Neither worked, the cyrilic characters were shown as ???.
My MySQL version is 5.5.27, but like i said without using connection pooling the character were shown correctly.
Any suggestions/ideas?

[Question] Handling Connections

Hey brettwooldridge,

I haven't worked with connectionpools a lot, and I stumbled upon the question what I have to do in the finally-block of queries. So without a connection-pool I closed the PreparedStatement, the ResultSet and the Connection. Which of them do I have to close in the finally-block while using HikariCP as ConnectionPool?

Thanks in Advance!
Scrayos

MBean Stuff

Hi,

Not sure if also related to the previous issue, but on shut-down of the app, I now get get:

[13:22:58.900] [               ] [DEVELOPMENT] [WARN ] [com.zaxxer.hikari.pool.HikariMBeanElf   ] [99  ] - Unable to unregister management beans.
javax.management.InstanceNotFoundException: com.zaxxer.hikari:type=Pool (corePool)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095) ~[na:1.8.0]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427) ~[na:1.8.0]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415) ~[na:1.8.0]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546) ~[na:1.8.0]
    at com.zaxxer.hikari.pool.HikariMBeanElf.unregisterMBeans(HikariMBeanElf.java:90) ~[HikariCP-1.3.8.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.shutdown(HikariPool.java:239) [HikariCP-1.3.8.jar:na]
    at com.zaxxer.hikari.HikariDataSource.shutdown(HikariDataSource.java:225) [HikariCP-1.3.8.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:349) [spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]

-=david=-

Add Spring setup to documentation (ideas included)

Hey @brettwooldridge, finally getting around to playing with HikariCP/Hibernate on a non-profit I support (nlfw.org). Working beautifully so far. Very, very glad to delete C3P0 from the dependencies ;)

For what it's worth, this is my Spring configuration. It might be beneficial to throw something like this in your docs.

https://gist.github.com/brmeyer/bbb8688658dd71752738

Note that I'm using the annotation-based Spring configuration, but the concepts would be similar through XML.

Just thought I'd throw that out there!

PropertyBeanSetter fails to set DataSource#url for some databases

Slightly older versions of H2 provide JdbcDataSource#setURL, but not JdbcDataSource#setUrl. That was corrected in a recent revision, however it will cause issues for many Hibernate users. Could PropertyBeanSetter#setTargetFromProperties be improved to handle crappy JDBC impls? ;)

I'm including a workaround in hibernate-hikaricp, for now.

Thanks!

NoClassDefFoundError

I don't think the main issue is from you but actually that what append:

I run some tests from Maven 3.2.1 that use your lib v1.3.3 on centos 6.5 64b.
I got a Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.zaxxer.hikari.HikariConfig. Classpath look fine with debug mode enable to maven.
It work fine on Windows and even at runtime on centos.

Do you have any clue? The only thing different is the maven lib name that start with an uppercase and everything else with a lowercase.

Maybe did you know how to force a lib to maven.

Thanks

Postgres Issue

I keep getting these errors even though there are very few connections open. I changed over to DBCP and no issues.

[ERROR] com.zaxxer.hikari.HikariPool - Maximum connection creation retries exceeded: FATAL: remaining connection slots are reserved for non-replication superuser connections
org.postgresql.util.PSQLException: FATAL: remaining connection slots are reserved for non-replication superuser connections
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:572) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:177) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:136) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:29) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.(AbstractJdbc3gConnection.java:21) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.jdbc4.AbstractJdbc4Connection.(AbstractJdbc4Connection.java:31) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.jdbc4.Jdbc4Connection.(Jdbc4Connection.java:24) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.Driver.makeConnection(Driver.java:410) ~[postgresql-9.3-1100-jdbc41.jar:na]
at org.postgresql.Driver.connect(Driver.java:280) ~[postgresql-9.3-1100-jdbc41

javax.sql.ConnectionPoolDataSource support

Current HikariCP solution contains of 2 parts

  1. Codegen/Proxy related stuff to wrap java.sql.Connection to something like javax.sql.PooledConnection
  2. Pool management code itself (inc thread syncronization, lifetime management etc)

Some JDBC drivers provide javax.sql.ConnectionPoolDataSource out-of the box. So bytecode generation isn't requred. I propose to split HikariCP for 2 lose-coupled parts:

  1. Codegen/Proxy related stuff to generate javax.sql.DataSource to exact javax.sql.ConnectionPoolDataSource adapter
  2. Pool management code to deal directly with javax.sql.ConnectionPoolDataSource api.

In this case you can use both parts if JDBC driver doesn't support javax.sql.ConnectionPoolDataSource and only second part otherwise...

Pool leaks connections open if customization/initSql fails

There seems to be slight a possibility to connection leak in the pool between acquiring a connection and adding it to the pool. Connection state reset has similar problem as well.

Steps to fix the issue (HikariPool.addConnection):

  1. Obtaining of a datasource connection should be closed (try/catch) in case of a failure prior it has been added to the pool
  2. initSql block should be followed by resetConnectionState in any case (try/finally)

[1.3.3] User is reporting overcommitted pool (600 connections at the DB)

I recently switched my Spring RESTful API data source from DriverManagerDataSource to HikariCp, but my database connections went from 20 connections to 600 connections. Is this suppose to happen?

My settings are as follows:

<bean id="jdbcDataSource"
    class="com.zaxxer.hikari.HikariDataSource" destroy-method="shutdown">
    <constructor-arg>
        <bean class="com.zaxxer.hikari.HikariConfig">
            <constructor-arg>
                <props>
                    <prop key="dataSource.url">url</prop>
                    <prop key="dataSource.user">user</prop>
                    <prop key="dataSource.password">password</prop>
                    <prop key="dataSource.cachePrepStmts">true</prop>
                    <prop key="dataSource.prepStmtCacheSize">250</prop>
                    <prop key="dataSource.prepStmtCacheSqlLimit">2048</prop>
                    <prop key="dataSource.useServerPrepStmts">true</prop>
                </props>
            </constructor-arg>
            <property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
        </bean>
    </constructor-arg>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="jdbcDataSource" />
</bean>

JavaAssist and Java 8

I'm getting a strange error when instantiating hikariCP when using java 8.
Here's a description of the problem:
http://www.symphonious.net/2014/03/21/javassist-java-8-invalid-constant-type-15/

The stacktrace is here:
at com.zaxxer.hikari.HikariConfig.(HikariConfig.java:82)
...
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:744)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: invalid constant type: 15
at com.zaxxer.hikari.proxy.JavassistProxyFactory.(JavassistProxyFactory.java:63)
... 6 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: invalid constant type: 15
at com.zaxxer.hikari.proxy.JavassistProxyFactory.(JavassistProxyFactory.java:103)
at com.zaxxer.hikari.proxy.JavassistProxyFactory.(JavassistProxyFactory.java:57)
... 6 more
Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 15

NPE in Hibernate when Connection accessed from thread that did not create it

Hi,

Just bumped up to the latest version (from 1.2.1) and now I'm getting this error, which is causing the transaction to rollback. This was okay on 1.2.1 (no code changes, just a version bump).

-=david=-

java.lang.NullPointerException: null
at com.zaxxer.hikari.proxy.ConnectionProxy._checkClosed(Unknown Source) ~[HikariCP-1.2.3.jar:na]
at com.zaxxer.hikari.proxy.ConnectionJavassistProxy.getAutoCommit(ConnectionJavassistProxy.java) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376) ~[spring-jdbc-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at com.sun.proxy.$Proxy21.getAutoCommit(Unknown Source) ~[na:na]
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:68) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:162) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1431) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.jpa.internal.TransactionImpl.begin(TransactionImpl.java:61) ~[hibernate-entitymanager-4.3.0.Final.jar:4.3.0.Final]
at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:67) ~[spring-orm-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:110) ~[spring-orm-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:380) ~[spring-orm-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
Wrapped by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:430) ~[spring-orm-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373) ~[spring-tx-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:420) ~[spring-tx-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:257) ~[spring-tx-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) ~[spring-tx-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92) ~[spring-data-jpa-1.5.0.M1.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.0.1.BUILD-SNAPSHOT.jar:4.0.1.BUILD-SNAPSHOT]
at com.sun.proxy.$Proxy109.save(Unknown Source) ~[na:na]

[1.2.8] Housekeeping timer thread never terminating / Connections remain opened

Hi,

I'm using HikariCP within a GlassFish 3.x application server. Datasources are created on demand, kept available for some time and closed after a certain timeout.

HikariPool#shutdown() currently isn't implemented, thus every datasource ever
created (and removed) "leaks" the associated connections as well as one timer
thread.

Probably, shutdown() should

  • close all connections
  • terminate the associated housekeeping timer thread

Meaning of "Value was returned to the bag that was not borrowed"?

I'm occasionally seeing the following error from my app:

! java.lang.IllegalStateException: Value was returned to the bag that was not borrowed
! at com.zaxxer.hikari.util.ConcurrentBag.requite(ConcurrentBag.java:177) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.zaxxer.hikari.HikariPool.releaseConnection(HikariPool.java:199) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.zaxxer.hikari.proxy.ConnectionProxy.close(ConnectionProxy.java:330) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mchange.v2.sql.filter.FilterConnection.close(FilterConnection.java:327) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.BasicHandle.close(BasicHandle.java:116) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$CloseHandler.invoke(CloseInternalDoNotUseThisClass.java:36) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:171) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObject$1.intercept(SqlObject.java:75) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$e389b236.___jdbi_close___(<generated>) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObject.close(SqlObject.java:184) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObjectBuilder.close(SqlObjectBuilder.java:76) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.DBI.close(DBI.java:353) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]

What could cause this error to occur? Is this indicative of a connection leak?

Dependency on Hibernate?

+-com.zaxxer:HikariCP:1.2.5
[info] | +-org.hibernate:hibernate-core:4.3.0.Final
[info] | | +-antlr:antlr:2.7.7
[info] | | +-dom4j:dom4j:1.6.1
[info] | | | +-xml-apis:xml-apis:1.0.b2
[info] | | |
[info] | | +-org.hibernate.common:hibernate-commons-annotations:4.0.4.Final
[info] | | | +-org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
[info] | | | +-org.jboss.logging:jboss-logging:3.1.3.GA
[info] | | |
[info] | | +-org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
[info] | | +-org.javassist:javassist:3.18.1-GA
[info] | | +-org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
[info] | | +-org.jboss.logging:jboss-logging:3.1.3.GA
[info] | | +-org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final
[info] | | +-org.jboss:jandex:1.1.0.Final
[info] | |
[info] | +-org.javassist:javassist:3.18.1-GA
[info] | +-org.slf4j:slf4j-api:1.7.5

Problem with MySQL recovery

Lars Gråmark has reported a scenario where HikariCP does not seem to recover successfully after MySQL connections are killed. This bug is to provide a place to attach materials related to the issue.

NPE for null password

Given the following config

<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
   <Arg></Arg>
   <Arg>jdbc/DSTest</Arg>
   <Arg>
     <New class="com.zaxxer.hikari.HikariDataSource">
       <Arg>
          <New class="com.zaxxer.hikari.HikariConfig">
             <Set name="minimumPoolSize">5</Set>
             <Set name="maximumPoolSize">50</Set>
             <Set name="dataSourceClassName">org.h2.jdbcx.JdbcDataSource</Set>
             <Call name="addDataSourceProperty">
                <Arg>url</Arg>
                <Arg>${jdbc.url}</Arg>
             </Call>
             <Call name="addDataSourceProperty">
                <Arg>user</Arg>
                <Arg>sa</Arg>
             </Call>
             <Call name="addDataSourceProperty">
                <Arg>password</Arg>
                <Arg></Arg>
             </Call>
          </New>
       </Arg>
    </New>
  </Arg>
</New>
Caused by: java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:394)
    at com.zaxxer.hikari.HikariConfig.addDataSourceProperty(HikariConfig.java:311)

is encountered.

HikariCP as JNDI Datasource

I have trying to test HikariCP as jndi datasource, but i cannot find the way to add it as jndi datasource in tomcat 7.
If it's possible can you provide the configuration or if not can you add this feature ?

Automatic rollback

Following my previous question on SO it would be nice to have automatic rollback for checked-in connections when their autoCommit is set to false.

Make metrics tracker optional

Currently CodaHaleMetricsTracker is required at compile/runtime to be present even when metrics are not recorded although pom.xml states scope provided. It would not help even if dependency would be marker as optional (as it should, same goes for hibernate).

I think that it would be better to initialize it from a given classname instead of boolean so that other metrics implementations could be used as well. That would fix this problem at the same time.

lastConnectionFailure causes null pointer

I'm trying to configure Hikari, but I'm getting a null pointer right now. HikariPool line 175:

        throw new SQLException(String.format("Timeout of %dms encountered waiting for connection.", configuration.getConnectionTimeout()), lastConnectionFailure.getAndSet(null));

lastConnectionFailure is null. Perhaps a null check is warranted?

Tomcat 7.0.50 shutdown issue

After updating HikariCP from 1.2.8 to 1.3.0 during shutdown Apache Tomcat 7.0.50 I'm getting these messages in catalina.log:

Mar 02, 2014 5:27:40 PM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Mar 02, 2014 5:27:40 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-apr-8080"]
Mar 02, 2014 5:27:40 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Mar 02, 2014 5:27:40 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Mar 02, 2014 5:27:40 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@af5dd35]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@4034afa3]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@4034afa3]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@af5dd35]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@af5dd35]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@af5dd35]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@4034afa3]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@4034afa3]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@af5dd35]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.zaxxer.hikari.util.ConcurrentBag$1](value [com.zaxxer.hikari.util.ConcurrentBag$1@1b6f3995]) and a value of type [java.util.LinkedList](value [[com.zaxxer.hikari.proxy.ConnectionJavassistProxy@af5dd35]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 02, 2014 5:27:40 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-apr-8080"]
Mar 02, 2014 5:27:40 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-apr-8009"]
Mar 02, 2014 5:27:40 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-apr-8080"]
Mar 02, 2014 5:27:40 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-apr-8009"]

Javassist to ASM

What does you think about migration from Javassist to ASM? I can help You to rewrite bytecode generation procedures.

Spring 3.2/Hibernate 4.3: Actual connection is closed upon return to pool

I am using Spring 4 with Hibernate 4.3 as a JPA provider.

Hibernate does not release connection back to pool when execute INSERT or UPDATE statement.

I tested with c3p0 and tomcat-jdbc have not this problem.

Here is my config:

<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource">
    <constructor-arg>
        <bean class="com.zaxxer.hikari.HikariConfig">
            <constructor-arg>
                <props>
                    <prop key="dataSource.url">${datasource.jdbcUrl}</prop>
                    <prop key="dataSource.user">${datasource.user}</prop>
                    <prop key="dataSource.password">${datasource.password}</prop>
                    <prop key="dataSource.cachePrepStmts">true</prop>
                    <prop key="dataSource.prepStmtCacheSize">250</prop>
                    <prop key="dataSource.prepStmtCacheSqlLimit">2048</prop>
                </props>
            </constructor-arg>
            <property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
            <property name="minimumPoolSize" value="5" />
            <property name="maximumPoolSize" value="15" />
            <property name="acquireIncrement" value="1" />
            <property name="maxLifetime" value="1800000" />
        </bean>
    </constructor-arg>
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="persistenceUnitName" value="DefaultDS"/>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>

            <prop key="hibernate.show.sql">false</prop>
            <prop key="hibernate.format_sql">false</prop>
            <prop key="hibernate.use_sql_comments">false</prop>
        </props>
    </property>
</bean>

logging bug in HikariMBeanElf.java

in HikariMBeanElf.java there is line:
LOGGER.error("No registered MBean for {0}.", configuration.getPoolName());

but slf4j doesn't work that way. it should just be {}.
the message i'm seeing in logs is:
No registered MBean for {0}.

Support forceClose for Sybase JConnect 7.0

ConnectionProxy.java implements a SQLState check to determine if a connection is in a broken state.

The current implementation supports the SQL 2003 standard and Postgres specific codes.

The Sybase JConnect driver has its own proprietary SQL state codes which are documented in the programmers manual available at http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc39001.0700/pdf/prjdbc0700.pdf

The state codes which should be treated as connection errors are:
"JZ0C0" - Connection is already closed
"JZ0C1" - An IOException occurred which closed the connection

Unfortunately the JConnect driver chains JZ0C1 inside a JZ006 exception - as documented by the pdf above. I have also experienced behavior where JZ0C0 has been chained inside a JZ006, although this is not mentioned by the spec. In spite of the description given, JZ0C0 can appear without invoking connection.close() explicitly.

The spec suggests that if a JZ006 occurs without any chained exceptions that the connection is still in a usable state - although I have never seen this particular scenario occur in my (limited) usage of the driver to date.

This suggests that a robust implementation would be to add both JZ0C0 and JZ0C1 to the SQL_ERRORS set and then change the behavior of checkException to check both sqle.sqlState and sqle.getNextException.sqlState (when defined) against the error list. JZ006 should not be treated as a connection error.

let me supply a DataSource to wrap

i might not have url/user/password - i might just have a DataSource from JNDI
which i'd like wrapped. BoneCP, one of your competitors :) lets me do that.

Allow DataSource configuration via driverClass

Setting the DataSource using e.g. org.postgresql.ds.PGSimpleDataSource seems to be less portable/ideal when supporting multiple DBs at the same time. E.g. PGSimpleDataSource does not provide for a JDBC url to be specified. Other pool implementations (e.g. BoneCP) provide more of an abstractions level so that I can set the DB properties across the various implementations e.g.

  • jdbcUrl
  • username
  • password
  • ...

Support for DataSource#setLogWriter

To see what is going on with the underlying DataSource (PGSimpleDataSource in my case) I use DataSource#setLogWriter. However, I did not find a way to do this with HikariCP.

What I tried:

PrintWriter logWriter = ...;

HikariConfig config = new HikariConfig();
// logWriter is first converted to String, so this does not work
config.addDataSourceProperty("logWriter", logWriter);
// other properties ...

HikariDataSource connectionPool = new HikariDataSource(config);
// Implementation does nothing
connectionPool.setLogWriter(logWriter);

Are there any plans to support this?

Thank you in advance and for your work so far, HikariCP is awesome. :)

Question: how to fail fast on bad DB password

Hi,
If my HikariCP config has the wrong database credentials, I'd like my server to fail fast.

Seems like the only way is to wait for acquireRetries * acquireRetryDelay milliseconds, then try to call getConnection(), catch the SQLException and then exit.

Do I have that right?

Thanks,
Mark

Transaction isolation applied to running transaction in HikariPool

I am running HikariCP 1.2.4 with

HikariConfig config = new HikariConfig();
config.setUseInstrumentation(false);
config.setJdbc4ConnectionTest(true);
config.setAutoCommit(false);
config.setTransactionIsolation("TRANSACTION_REPEATABLE_READ");

Because HikariPool does not reset the autocommit flag (to its default of true) when the connection is returned to the pool, this leads to (comments inline, code from HikariPool, line 152):

Connection connection = (Connection) connectionProxy;
// if connectionProxy is not autocommiting, this will start a transaction
if (!isConnectionAlive(connection, timeout))
{
    // Throw away the dead connection, try again
    closeConnection(connectionProxy);
    timeout -= (System.currentTimeMillis() - start);
    continue;
}

if (leakDetectionThreshold > 0)
{
    connectionProxy._captureStack(leakDetectionThreshold, houseKeepingTimer);
}
// if autocommit is already false, this is a noop, transaction still running
connection.setAutoCommit(isAutoCommit);
// Exception here, because transaction is already running
connection.setTransactionIsolation(transactionIsolation);
connection.clearWarnings();

I also noticed while debugging that postgres (in my case) will perform a roundtrip to the database on

Connection#setTransactionIsolation and also on Connection#getTransactionIsolation

Maybe the transaction isloation could be cached by HikariCP and only set once on creation of the actual connection?

Suppress warning message on connection death

So I had a connection die and HikariCP threw two huge warning messages into my log. Can I either suppress these or replace them with my own message? I don't really care if a connection sitting idle in the pool died, since a new one will just take its place. The first two lines from the two stack traces are below:

2014-04-30 01:00:11 [WARN] Connection com.amshulman.insight.lib.mysql.MySQLConnection@cf5011b (HikariPool-0) marked as broken because of SQLSTATE(08), ErrorCode(-1).
java.sql.SQLNonTransientConnectionException: Could not ping: unexpected end of stream, read 0bytes from 4

2014-04-30 01:00:11 [WARN] Exception during keep alive check, that means the connection must be dead.
java.sql.SQLNonTransientConnectionException: Could not ping: unexpected end of stream, read 0bytes from 4

NullPointerException within HikariDataSource.shutdown()

I have a encountered a NullPointerException using the close method of HikariDataSource (1.3.2) when using it as a spring bean.

Following use case. A declared a HikariCP data source as a spring bean in Java config manner. Here is the code:

@Bean(destroyMethod = "close")
  public HikariDataSource dataSource(@Value("${db.name}") String databaseName,
    @Value("${db.user}") String user, @Value("${dashboard.db.pass}") String password,
    @Value("${db.login.timeout.sec}") int loginTimeoutSec,
    @Value("${db.connect.timeout.ms}") final int connectionTimeoutMs,
    @Value("${db.max.pool.size}") final int maxPoolSize,
    @Value("${db.min.pool.size}") final int minPoolSize,
    @Value("${db.test.query}") final String connectionTestQuery,
    @Value("${db.acq.inc}") final int acquireIncrement) throws SQLException {

    MysqlDataSource mysqlDataSource = new MysqlDataSource();
    mysqlDataSource.setDatabaseName(databaseName);
    mysqlDataSource.setUser(user);
    mysqlDataSource.setEncoding("UTF-8");
    mysqlDataSource.setUseUnicode(true);
    if (!Strings.isNullOrEmpty(password)) {
      mysqlDataSource.setPassword(Aes.decrypt(password));
    }

    HikariDataSource dataSource = new HikariDataSource();
    dataSource.setLoginTimeout(loginTimeoutSec); // sec
    dataSource.setPoolName("dashboard-server-pool");
    dataSource.setConnectionTimeout(connectionTimeoutMs); // ms
    dataSource.setMaximumPoolSize(maxPoolSize);
    dataSource.setMinimumPoolSize(minPoolSize);
    dataSource.setJdbc4ConnectionTest(false);
    dataSource.setConnectionTestQuery(connectionTestQuery);
    dataSource.setAcquireIncrement(acquireIncrement);
    dataSource.setAcquireRetries(1);
    dataSource.setAcquireRetryDelay(1000); // ms
    dataSource.setDataSource(mysqlDataSource);

    return dataSource;
  }

As you can see, I am using "close()" as Spring destroy method when shutting down the app. The "close()" effectively does nothing more then delegating to "shutdown()". When shutting down the app, a NullPointerException was raised for HikariDataSource:167.

The code there shows that the internal pool instance was not instantiated at that time.

/**
     * Shutdown the DataSource and its associated pool.
     */
    public void shutdown()
    {
        boolean shutdown = isShutdown;
        isShutdown = true;
        if (!shutdown)
        {
            pool.shutdown();
            pool = null;
        }
    }

I noticed that this is a rare use case, because it only happened because Spring started up but no connection had been used so far, so no pool was created and when the app shuts down the NullPointer was raised.

I managed to workaround this splitting the declaration up into HikariConfig and HikariDataSource. Here is the code:

@Bean(destroyMethod = "close")
  public HikariDataSource dataSource(@Value("${db.name}") String databaseName,
    @Value("${db.user}") String user, @Value("${db.pass}") String password,
    @Value("${db.login.timeout.sec}") int loginTimeoutSec,
    @Value("${db.connect.timeout.ms}") final int connectionTimeoutMs,
    @Value("${db.max.pool.size}") final int maxPoolSize,
    @Value("${db.min.pool.size}") final int minPoolSize,
    @Value("${db.test.query}") final String connectionTestQuery,
    @Value("${db.acq.inc}") final int acquireIncrement) throws SQLException {

    MysqlDataSource mysqlDataSource = new MysqlDataSource();
    mysqlDataSource.setDatabaseName(databaseName);
    mysqlDataSource.setUser(user);
    mysqlDataSource.setEncoding("UTF-8");
    mysqlDataSource.setUseUnicode(true);
    if (!Strings.isNullOrEmpty(password)) {
      mysqlDataSource.setPassword(Aes.decrypt(password));
    }

    HikariConfig config = new HikariConfig();
    config.setPoolName("dashboard-server-pool");
    config.setConnectionTimeout(connectionTimeoutMs); // ms
    config.setMaximumPoolSize(maxPoolSize);
    config.setMinimumPoolSize(minPoolSize);
    config.setJdbc4ConnectionTest(false);
    config.setConnectionTestQuery(connectionTestQuery);
    config.setAcquireIncrement(acquireIncrement);
    config.setAcquireRetries(1);
    config.setAcquireRetryDelay(1000); // ms
    config.setDataSource(mysqlDataSource);

    HikariDataSource dataSource = new HikariDataSource(config);
    dataSource.setLoginTimeout(loginTimeoutSec); // sec

    return dataSource;
  }

The constructor call of HikariDataSource that takes the HikariConfig parameter initialises the pool within the constructor, so the NullPointerException was not raised during shutdown.

My question is, am I missing something obvious here or is the different behaviour of the HikariDataSource constructors the desired behaviour? Is the initialisation of the pool instance missing from no arg constructor?

SQL logging

Please add sql operations logging (insert, delete, update, select) like in bonecp

it don't work :(

I'm using my custom ClassLoader (nothing special, just this)

            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(new ClassLoader(contextClassLoader) {
            });

Seems like bytecode modifications doesn't take effect :(

            IHikariConnectionProxy proxyConnection = ProxyFactory.getProxyConnection(this, connection, transactionIsolation, isAutoCommit, isReadOnly, catalog);
            proxyConnection.resetConnectionState();

proxyConnection is null (seems like no code generation affected) !!!

        JavassistProxyFactory.initialize();
        HikariConfig config = new HikariConfig();
        setBeanValues(properties, config);
        config.setPassword(null);
        config.setUsername(null);
        config.setDataSource(dataSource);
        return new HikariDataSource(config);

removing custom classloader fixes issue

Consider adding HikariConfig#setTransactionIsolation

I'm using HikariCP together with Spring and it would be nice to specify a default transaction level for handed out connections.

Called like:

HikariConfig config = new HikariConfig();
// Taking transaction name (Connection.TRANSACTION_REPEATABLE_READ)
// so that configuration in properties file is readable
config.setTransactionIsolation("TRANSACTION_REPEATABLE_READ");

If the underlying DataSource would allow it, HikariConfig#addDataSourceProperty could be used, but in the case of postgres, PGSimpleDataSource has no appropriate setter.

IndexOutOfBoundsException in close()

There's a little problem lying in ConnectionProxy.close().

Example case:

try(final Connection con = Pool.getInstance().getConnection())
{
    // e.g forgot to close.
    con.createStatement();
    con.createStatement();
}
catch (SQLException e)
{
    e.printStackTrace();
}

This one leads to this:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
        at java.util.ArrayList.rangeCheck(ArrayList.java:635)
        at java.util.ArrayList.get(ArrayList.java:411)
        at com.zaxxer.hikari.proxy.ConnectionProxy.close(Unknown Source)

The cause of this is simple. The size of openStatements stored as a constant.
Then, when the statement is closed (unregisterStatement) - it'll be removed from the List and therefore we cannot use the size constant again which is used for loop as it is points to invalid index (from now).

p.s Shouldn't there be a option for logging such "unclosed" resources? :)

HikariPool does not implement DynamicMBean

Hi,

Java 1.8u5
HikariCP 1.3.7
Spring 4.0.3.RELEASE

Upgraded from 1.3.6 to 1.3.7 of HikariCP. I now get this exception on startup:

16:12:01.258] [               ] [DEVELOPMENT] [WARN ] [com.zaxxer.hikari.pool.HikariMBeanElf   ] [69  ] - Unable to register management beans.
javax.management.NotCompliantMBeanException: MBean class com.zaxxer.hikari.pool.HikariPool does not implement DynamicMBean, and neither follows the Standard MBean conventions (javax.management.NotCompliantMBeanException: Class com.zaxxer.hikari.pool.HikariPool is not a JMX compliant Standard MBean) nor the MXBean conventions (javax.management.NotCompliantMBeanException: com.zaxxer.hikari.pool.HikariPool: Class com.zaxxer.hikari.pool.HikariPool is not a JMX compliant MXBean)
    at com.sun.jmx.mbeanserver.Introspector.checkCompliance(Introspector.java:176) ~[na:1.8.0_05]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:317) ~[na:1.8.0_05]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) ~[na:1.8.0_05]
    at com.zaxxer.hikari.pool.HikariMBeanElf.registerMBeans(HikariMBeanElf.java:60) ~[HikariCP-1.3.7.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:128) [HikariCP-1.3.7.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:91) [HikariCP-1.3.7.jar:na]
    at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:69) [HikariCP-1.3.7.jar:na]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:1.8.0_05]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [na:1.8.0_05]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:1.8.0_05]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408) [na:1.8.0_05]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148) [spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:125) [spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]

Connections marked as broken

Hey, first of all I'm sorry for creating another Issue but it's definetely not related to new versions, but HikariCP (Or my Implementation of it) in general.

Every X. connection I get from the pool seems to be broken:
[SEVERE] [Netty IO Thread #2] WARN com.zaxxer.hikari.proxy.ConnectionProxy - Connection com.mysql.jdbc.JDBC4Connection@38dfa9cc marked as broken because of SQLSTATE(08003), ErrorCode(0): null

I just get a connection with try (Connection cn = JCProxy.getInstance().getMysqlHandler().getConnection()) { and it should be closed automatically at the end of the try-catch-block.

The strangest thing about is that every snippet of my code has its own "Interval-of-broken-Connection" as it seems. I got a Plugin for a Minecraft-Proxy-Software. In this plugin there are some Commands. In one command every 2nd connection is broken in another plugin every 3rd connection is broken ... I'm unsure if it's randomly or I am doing something wrong if you want I could send you the full code from one of the commands.

Exception during keep alive check

Right after updating from 1.2.4 to 1.2.6 i've encountered with a strange behaviour.
The DB (MySQL) itself is okay. A bug, i guess?
So here it is (these are the postponed tasks):

[ERROR 14:40:52]: Exception during keep alive check.  Connection must be dead.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 746,568 milliseconds ago.  The last packet sent successfully to the server was 2 milliseconds ago.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1129)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3720)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3609)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4160)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2819)
        at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5355)
        at com.zaxxer.hikari.proxy.ConnectionJavassistProxy.setAutoCommit(ConnectionJavassistProxy.java)
        at com.zaxxer.hikari.HikariPool.isConnectionAlive(Unknown Source)
        at com.zaxxer.hikari.HikariPool.getConnection(Unknown Source)
        at com.zaxxer.hikari.HikariDataSource.getConnection(Unknown Source)
        ...
        ...
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        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:744)
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3166)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3620)
        ... 25 more

The database log also contains this, many of them.
Also, i've seen it before, within previous releases of HikariCP.
Don't know if it is a normal behaviour, but i never seen so much "aborted connections" in log when been using BoneCP, for example.

140115 15:10:02 [Warning] Aborted connection 216 to db: 'server' user: 'user' host: 'localhost' (Unknown error)
140115 15:10:32 [Warning] Aborted connection 217 to db: 'server' user: 'user' host: 'localhost' (Unknown error)
140115 15:11:02 [Warning] Aborted connection 218 to db: 'server' user: 'user' host: 'localhost' (Unknown error)
140115 15:11:32 [Warning] Aborted connection 219 to db: 'server' user: 'user' host: 'localhost' (Unknown error)

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.