Fief causes numerous idle sessions in PostgreSQL #383
Replies: 1 comment 2 replies
-
We do use a context manager to manage session lifetime: Lines 9 to 19 in 9c7e72e It's done implicitly by FastAPI, but it's there. What's happening however is that SQLAlchemy maintains connection pools (i.e. idle opened connection ready to answer incoming queries). The default of SQLAlchemy is 5 opened connections at most. The thing is, they can pile up quite quickly if you have several server processes. We don't have a setting right now to tweak the number of connections, but it should probably be added. Meanwhile, I suggest you to reduce the number of processes of the server: set the |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
In my database, I can see numerous idle sessions that caused an outage. No more clients were allowed in my PostgreSQL
To Reproduce
Expected behavior
Sessions will be closed correctly
Configuration
Additional context
I recommend to use a contextmanager to handle database sessions:
Beta Was this translation helpful? Give feedback.
All reactions