{"action":"created","issue":{"url":"https://api.github.com/repos/brettwooldridge/HikariCP/issues/418","labels_url":"https://api.github.com/repos/brettwooldridge/HikariCP/issues/418/labels{/name}","comments_url":"https://api.github.com/repos/brettwooldridge/HikariCP/issues/418/comments","events_url":"https://api.github.com/repos/brettwooldridge/HikariCP/issues/418/events","html_url":"https://github.com/brettwooldridge/HikariCP/issues/418","id":106518934,"number":418,"title":"HikariPool.getConnection freezes in certain circumstances","user":{"login":"Bhashit","id":5462389,"avatar_url":"https://avatars.githubusercontent.com/u/5462389?v=3","gravatar_id":"","url":"https://api.github.com/users/Bhashit","html_url":"https://github.com/Bhashit","followers_url":"https://api.github.com/users/Bhashit/followers","following_url":"https://api.github.com/users/Bhashit/following{/other_user}","gists_url":"https://api.github.com/users/Bhashit/gists{/gist_id}","starred_url":"https://api.github.com/users/Bhashit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bhashit/subscriptions","organizations_url":"https://api.github.com/users/Bhashit/orgs","repos_url":"https://api.github.com/users/Bhashit/repos","events_url":"https://api.github.com/users/Bhashit/events{/privacy}","received_events_url":"https://api.github.com/users/Bhashit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/brettwooldridge/HikariCP/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2015-09-15T09:32:52Z","updated_at":"2015-09-17T12:51:46Z","closed_at":null,"body":"Hi,\r\n\r\nI 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. \r\n\r\nAnother 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).\r\n\r\nThe various versions of libraries/tools that I am using are:\r\n\r\n1. Play Framework 2.4.2 (with hikari has the default pool)\r\n2. Hibernate 5 (recently upgraded from 4.3.8)\r\n3. Postgres 9.4\r\n4. Ubuntu 14.04\r\n5. Oracle JDK 1.8.0_45\r\n\r\nThis is my config in play:\r\n\r\n      logSql=true\r\n      dataSourceClassName=org.postgresql.ds.PGSimpleDataSource\r\n      connectionTestQuery=\"SELECT 1\"\r\n      initializationFailFast=true\r\n      maximumPoolSize=10\r\n      autoCommit=false\r\n      dataSource {\r\n        user=xxxxxx\r\n        password=xxxxxx\r\n        databaseName=xxxxxxx\r\n        serverName=localhost\r\n      }\r\n\r\nI took the thread dump using jstack while hibernate was blocked, the relevant parts of which look like this:\r\n\r\n     \"ForkJoinPool-1-worker-1\" #46 daemon prio=5 os_prio=0 tid=0x00007f0945f68000 nid=0xd29 waiting on condition [0x00007f093444e000]\r\n    java.lang.Thread.State: TIMED_WAITING (parking)\r\n    at sun.misc.Unsafe.park(Native Method)\r\n    - parking to wait for  <0x00000000d1727b08> (a com.zaxxer.hikari.util.QueuedSequenceSynchronizer$Synchronizer)\r\n    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)\r\n        at java.util.concurrent.locks.AbstractQueuedLongSynchronizer.doAcquireSharedNanos(AbstractQueuedLongSynchronizer.java:815)\r\n        at java.util.concurrent.locks.AbstractQueuedLongSynchronizer.tryAcquireSharedNanos(AbstractQueuedLongSynchronizer.java:1106)\r\n        at com.zaxxer.hikari.util.QueuedSequenceSynchronizer.waitUntilSequenceExceeded(QueuedSequenceSynchronizer.java:92)\r\n        at com.zaxxer.hikari.util.ConcurrentBag.borrow(ConcurrentBag.java:159)\r\n        at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:182)\r\n        at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:163)\r\n        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:85)\r\n        at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)\r\n        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)\r\n        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)\r\n        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)\r\n       at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)\r\n\r\n\r\n\r\n\r\nAnd here's the debug-log while hibernate seems to be stuck:\r\n\r\n    [info] c.z.h.HikariDataSource - HikariPool-0 - is starting.\r\n    [debug] c.z.h.p.PoolElf - HikariPool-0 - Connection.setNetworkTimeout() is not supported (org.postgresql.jdbc4.Jdbc4Connection.getNetworkTimeout()I)\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@26ccc54a\r\n    [debug] c.z.h.p.PoolElf - HikariPool-0 - Reset (autoCommit) on connection org.postgresql.jdbc4.Jdbc4Connection@26ccc54a\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@319e194b\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@3f59e108\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@3b66723b\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@7e64eb33\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@3ff1e1f5\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@4fd016a2\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@47af42c9\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@1e4b147c\r\n    [debug] c.z.h.p.HikariPool - HikariPool-0 - Added connection org.postgresql.jdbc4.Jdbc4Connection@2e05a009\r\n    [debug] c.z.h.p.HikariPool - After fill\tpool HikariPool-0 stats (total=10, active=0, idle=10, waiting=0)\r\n    [debug] c.z.h.p.PoolElf - HikariPool-0 - Reset (autoCommit) on connection org.postgresql.jdbc4.Jdbc4Connection@319e194b\r\n    [debug] c.z.h.p.PoolElf - HikariPool-0 - Reset (autoCommit) on connection org.postgresql.jdbc4.Jdbc4Connection@26ccc54a\r\n    [debug] c.z.h.p.PoolElf - HikariPool-0 - Statement.setQueryTimeout() is not supported (Method org.postgresql.jdbc4.Jdbc4Statement.setQueryTimeout(int) is not yet implemented.)\r\n    HikariConnectionProxy@360951608 wrapping org.postgresql.jdbc4.Jdbc4Connection@26ccc54a\r\n    [debug] c.z.h.p.HikariPool - Before cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - After cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - Before cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - After cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - Before cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - After cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - Before cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - After cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - Before cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - After cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - Before cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n    [debug] c.z.h.p.HikariPool - After cleanup\tpool HikariPool-0 stats (total=10, active=10, idle=0, waiting=1)\r\n\r\n\r\nThe 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.\r\n\r\nI 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`.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/brettwooldridge/HikariCP/issues/comments/141071767","html_url":"https://github.com/brettwooldridge/HikariCP/issues/418#issuecomment-141071767","issue_url":"https://api.github.com/repos/brettwooldridge/HikariCP/issues/418","id":141071767,"user":{"login":"brettwooldridge","id":1538661,"avatar_url":"https://avatars.githubusercontent.com/u/1538661?v=3","gravatar_id":"","url":"https://api.github.com/users/brettwooldridge","html_url":"https://github.com/brettwooldridge","followers_url":"https://api.github.com/users/brettwooldridge/followers","following_url":"https://api.github.com/users/brettwooldridge/following{/other_user}","gists_url":"https://api.github.com/users/brettwooldridge/gists{/gist_id}","starred_url":"https://api.github.com/users/brettwooldridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettwooldridge/subscriptions","organizations_url":"https://api.github.com/users/brettwooldridge/orgs","repos_url":"https://api.github.com/users/brettwooldridge/repos","events_url":"https://api.github.com/users/brettwooldridge/events{/privacy}","received_events_url":"https://api.github.com/users/brettwooldridge/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T12:51:46Z","updated_at":"2015-09-17T12:51:46Z","body":"@Shredder121 Sorry, I was on the train ealier and somehow missed [this comment](https://github.com/brettwooldridge/HikariCP/issues/418#issuecomment-141037911).  That is a big clue... looking into it.\r\n"}}