Close JDBC connections before releasing an idled-out worker thread #162
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "close-jdbc-connections-on-idle-timeout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #161.
RequestEvaluator.notifyAndWait()nulledthread/transactoron theInterruptedExceptionand idle-timeout paths without first callingtx.closeConnections(), unlike every other exit path in the class (thefinallyinrun(),stopTransactor(), and the “another thread already took over” branch earlier in the same method). The cached JDBC connection then had nothing telling the driver to close its socket, so it stayed open until the driver's own finalizer ran (unreliable) or the database'swait_timeoutclosed it server-side — one leaked connection per idled-out worker thread.This adds the same
Transactor.getInstance()/closeConnections()call already used elsewhere in the file to both gap branches. No other behavior changes.See the issue for the production evidence (245+ idle MariaDB connections against 55 live OS threads on a long-running instance) and why this also covers scheduled/cron jobs, which route through the same
RequestEvaluator/Transactormachinery viaCronRunner→invokeInternal().Closing without merging — this was on the wrong track. See the comment on #161:
tx.closeConnections()already runs for both theInterruptedExceptionand idle-timeout exits, via thefinallyblock wrappingrun()'s outer loop (in place since 2005, well before the currently deployedhelma-20190209.jar). A live test on antville-dev confirmed connections clear correctly on idle timeout even without this change.The actual leak is filed as #163, fix incoming in a separate PR.
Pull request closed