Correct way to configure Hikari CP timeout with slick 3.1.1

1,356 views
Skip to first unread message

Mike Nielsen

unread,
Aug 12, 2016, 7:04:39 PM8/12/16
to Slick / ScalaQuery
Hi!

"com.typesafe.slick" %% "slick" % "3.1.1",
"com.typesafe.slick" %% "slick-hikaricp" % "3.1.1",

I am new to slick today; I'd like to use it with my Google Cloud MySQL 5.6 DB instance from my Scala app.

When I configured slick to suppress using a connection pool, I could read and write to my database.

However, when I configure a connection pool, which will be my eventual use-case, I get a connection timeout. 

Since my database instance shuts down after a period of inactivity, it can take several seconds to be able to establish a connection; 1 second isn't really quite enough for my purposes.

I've been searching high and low and can't really see how to configure this connection timeout.   I've tried "connectionTimeout = " in various places in my configuration, but I can't seem to affect this particular item.

I see the hikaricp documentation refers to a connectionTimeout of 30 seconds, so I can't understand why I only get 1 second.

It would be great if I could put it in my application.conf file in the "preferred" manner (i.e, mydb={...})

NB: I'm not using Play! with this particular application.

I feel I'm missing out on some important piece of documentation: I can't seem to really piece it together from the scaladocs.

Any help would be received with warmth and gratitude!

12 [mydb-1] DEBUG com.zaxxer.hikari.pool.HikariPool - Timeout failure pool stats mydb (total=0, inUse=0, avail=0, waiting=0)
18:10:03.416 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariCP pool mydb is shutting down.
18:10:03.416 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - Before shutdown pool stats mydb (total=0, inUse=0, avail=0, waiting=0)
18:10:04.936 [HikariCP connection filler (pool mydb)] INFO com.zaxxer.hikari.util.ConcurrentBag - ConcurrentBag has been closed, ignoring add()
18:10:04.936 [HikariCP connection filler (pool mydb)] DEBUG com.zaxxer.hikari.pool.PoolUtilities - Closing connection com.mysql.jdbc.JDBC4Connection@799e93f5
18:10:04.939 [HikariCP connection filler (pool mydb)] DEBUG com.zaxxer.hikari.pool.HikariPool - Connection attempt to database mydb failed: ConcurrentBag has been closed, ignoring add()
java.lang.IllegalStateException: ConcurrentBag has been closed, ignoring add()
at com.zaxxer.hikari.util.ConcurrentBag.add(ConcurrentBag.java:178)
at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:453)
at com.zaxxer.hikari.pool.BaseHikariPool$1.run(BaseHikariPool.java:413)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
18:10:05.142 [HikariCP connection filler (pool mydb)] DEBUG com.zaxxer.hikari.pool.HikariPool - After fill pool stats mydb (total=0, inUse=0, avail=0, waiting=0)
18:10:05.143 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - After shutdown pool stats mydb (total=0, inUse=0, avail=0, waiting=0)
Exception in thread "main" java.sql.SQLTimeoutException: Timeout after 1001ms of waiting for a connection.
at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:227)

Mike Nielsen

unread,
Aug 12, 2016, 8:02:49 PM8/12/16
to Slick / ScalaQuery
Never mind.  

I guess it's been a long day; I was looking at the wrong application.conf

The connectionTimeout setting is honored as expected.
Reply all
Reply to author
Forward
0 new messages