Session connections not properly released when using FastAPI Depends, causing connection pool exhaustion #1417
Unanswered
R-Hichem-ansys
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Bug Description
When using SQLModel Session with FastAPI's Depends() dependency injection, database connections are not properly released back to the connection pool after request completion. This leads to connection pool exhaustion and application blocking when the pool limit is reached.
Environment
SQLModel version: 0.0.24
FastAPI version: 0.115.14
Database: SQLite
Python version: 3.12.5
Expected Behavior
Database connections should be automatically released back to the connection pool after each request completes, allowing the application to handle concurrent requests without exhausting the pool.
Actual Behavior
Connections remain checked out from the pool and are not released, causing:
Steps to Reproduce
If you change the endpoint to hit the
/user-session-begin
, notice that this issue does not happen.##Questions
Operating System
Linux
Operating System Details
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
UBUNTU_CODENAME=noble
SQLModel Version
0.024
Python Version
3.12.5
Additional Context
sample k6 script to load test
Beta Was this translation helpful? Give feedback.
All reactions