Close stale JDBC connection before replacing it on db.properties reload #164
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "close-stale-connection-on-db-properties-reload"
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 #163.
DbSource.getConnection()opens a replacement connection wheneverdb.propertieshas been modified since it was last read (fileUpdated), but the branch also fires when the currently cached connection is still open and healthy — in that case the old connection was discarded and overwritten in the cache (tx.registerConnection(...)/connection.set(...)) without ever being closed. Every thread that still held a live connection to thatDbSourceat the moment of the reload leaked one open socket.This adds an explicit close of the stale connection, guarded so it only runs when there actually is one to close (the
con == nullandcon.isClosed()cases already have nothing to close).Note: #161 / PR #162 chased a different, incorrect diagnosis (worker-thread idle timeout) — that path already closes connections correctly via the
finallyblock inRequestEvaluator.run(), in place since 2005. Both are closed; this is the real fix.Tested live on antville-dev (ct 3080): deployed this branch via the 'Deploy' workflow (
hostname: antville-test.de), then reproduced the exact sequence that shows the bug — warm up a connection, touchdb.properties, wait past the 1.5sResourcePropertiescache window, make another request.Before this fix (on the unpatched build), that sequence grew the connection count 2→3, leaving the old connection orphaned alongside the new one. With this build (
helma-26.9.6.jar), it's a clean 1-for-1 swap both times I ran it — old port gone, new port in its place, connection count never grows, thread count steady at 30 throughout.Merging.