pgstac icon indicating copy to clipboard operation
pgstac copied to clipboard

Database connections are never closed

Open Zaczero opened this issue 11 months ago • 5 comments

PgstacDB maintains a persistent connection to the database through self.connection = pool.getconn(). According to the getconn() documentation, this connection will not be automatically returned to the pool, and therefore won't be closed when idle. An explicit putconn() call is required. Currently, db_max_idle is ignored, which leads to database timeouts during long idle periods. I suggest not implementing a custom self.connection singleton pooling logic, but rather relying on the psycopg_pool implementation. Otherwise, you would need to implement the same feature set as psycopg_pool, including idle handling, which adds unnecessary complexity.

Zaczero avatar Jan 23 '25 13:01 Zaczero