Details
-
Bug
-
Resolution: Fixed
-
Major
-
3.15.0
-
None
Description
We experienced reaching the maximum number of allowed connections from our pre-production PostgreSQL server when deploying NetArchive Suite 3.15.0.
An investigation of the code, and especially DAO-related classes and DBConnect, showed that the code here assumes that connections will automatically time out, and thus does never explicitly closes connections.
Furthermore, it is very unconventional to map a DB connection per Thread, especially if we store such a mapping in a WeakHashMap : debugging revealed that there are many still valid connections that are left open when a dead thread is garbage collected (and hence the corresponding mapping silently removed from the map).
The proper solution is to refactor the DBConnect class to use a standard, production-quality, DB connection pool API, and ensuring in all DAO classes that connections are properly returned to the pool.