Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database connections are never closed #340

Open
Zaczero opened this issue Jan 23, 2025 · 1 comment
Open

Database connections are never closed #340

Zaczero opened this issue Jan 23, 2025 · 1 comment

Comments

@Zaczero
Copy link

Zaczero commented Jan 23, 2025

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
Copy link
Author

Zaczero commented Jan 31, 2025

I could prepare a PR dropping the singleton caching and moving all caching logic to the psycopg_pool (as it should imo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant