Open DeMol-EE opened 5 years ago
In follow up I'd like to add I've discovered another situation in which a connection is leaked, namely on db.execute
and db.insert
when the query results in a SQLException. I will try to upload a MVC example soon.
Okay, I'm on vacation but I'll look at it when I get back in a few days. If you can please confirm it's not an issue with Hikari or the MySQL driver and that it is RxKotlin-JDBC that is the source of the issue
Hmm... yes there is something that doesn't look right here when comparing the implementation of insert()
and execute()
. The insert()
relies on the iterator of toObservable()
to close the connection whereas the execute()
does nothing with the autoClose
argument. I'll take care of this.
@Warkst Alright, I implemented a fix. Can you test a build? You can use JitPack to bring this in as a dependency: https://jitpack.io/#thomasnield/rxkotlin-jdbc/596332118a
Thanks @thomasnield for looking into this. I'm still experiencing connection leaks when something like
db.execute("some pre-built insert statement").toSingle().blockingGet()
results in an exception.
Hi! Has this issue been resolved yet?
Any updates on this??
I'm using rxkotlin-jdbc and a Hikari data source in a TornadoFX project and found that a connection is leaking whenever I use
fun DataSource.execute
to delete objects from an underlying PostgreSQL database. I came across this by enabling logging with the JVM parameter-Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=debug
and setting the hikari config'sleakDetectionThreshold
property to 60_000 ms, which showed the following output in my console:The specific function in violation:
jdk: 1.8.0_144 kotlin version: 1.3.10 rxkotlinfx maven version: 2.2.2 hikaricp maven version: 3.2.0
Not sure this is a bug of Hikari or rxkotlin-jdbc, but I found that swapping the
execute
toinsert
(andtoSingle()
totoSingle{true}
) fixes the leak. Seems like the connection is not being closed and returned to the pool correctly?