Open Adam- opened 6 years ago
Sorry to repeat my comment from #202, but I have found this fix to be a good fix
for a problem I had with a very different test case than others perhaps. I was
testing sql2o with transactions using 1.6.0 on Quarkus with Agroal connection polling and noticed
Agroal leak warnings like: Datasource '
Sorry to repeat my comment from #202, but I have found this fix to be a good fix for a problem I had with a very different test case than others perhaps. I was testing sql2o with transactions using 1.6.0 on Quarkus with Agroal connection polling and noticed Agroal leak warnings like: Datasource '': JDBC resources leaked: 2 ResultSet(s) and 2 Statement(s). With this fix (#300), however, the warnings went away. I am eager to see this get into master... and also eager for the next release with it... as this seems to me like a very important fix.
I was able to work around this in my code via:
query.executeBatch();
con.commit(false);
at every place that I open a transaction
There are still leaks with the above suggestion (batch), and I suspect the important difference is that I am testing with a quality leak detection connection pool, Quarkus Agroal, which is much better at leak detection than some other connection poolers (e.g. dbcp). I have found Agroal excellent at finding leaks in my own raw JDBC. https://agroal.github.io/. What connection pooler were you testing with?
A second issue is that using batch is not a sufficient solution (even if it did work).
I applied this pull request to sql2o and it solves the transaction leak issue!
Closing the connection with closeJdbcConnection() prevented close() from closing registered statements. Closes #202.