Fork me on GitHub
#sql
<
2018-07-04
>
Niclas09:07:40

I’m running a simple ring/Jetty app with clojure.java.jdbc wrapped with hikari-cp for connection pooling. Sporadically I get this error:

...
my.handler/handle handler.clj:100
clojure.java.jdbc/db-transaction* jdbc.clj: 598
clojure.java.jdbc/db-transaction* jdbc.clj: 629
clojure.java.jdbc/db-transaction* jdbc.clj: 623
com.zaxxer.hikari.pool.HikariProxyConnection.setAutoCommit HikariProxyConnection.java
com.zaxxer.hikari.pool.ProxyConnection.setAutoCommit ProxyConnection.java: 388
com.sun.proxy.$Proxy11.setAutoCommit
com.zaxxer.hikari.pool.ProxyConnection$ClosedConnection.lambda$getClosedConnection$0 ProxyConnection.java: 489
java.sql.SQLException: Connection is closed
errorCode: 0
AFAICT this means that the connection is closed during the transaction, which I suspect can happen either if a transaction takes too long to complete or another thread has closed the connection. Does anybody have any thoughts on how I can debug the issue further?

seancorfield16:07:15

I'm not familiar with Hikari -- we use c3p0 -- but I would expect you can adjust connection pool timeouts and so on. We had to spend a while tuning that stuff before we were happy in production (with MySQL).

seancorfield16:07:55

@looveh Maybe you can share the Clojure code both for the with-db-transaction that fails and for how you set up Hikari?