Conversation
…my engines - Eliminated duplicate create_async_engine() in user_model.py; now reuses the single engine from db/session.py - Increased pool_size from 5 to 20, max_overflow from 10 to 40, and pool_timeout from 30s to 60s on the shared engine - Fixes 'QueuePool limit of size 5 overflow 10 reached' timeout errors
SQLite serializes writes at the file level so connection pooling provides no benefit and can cause QueuePool exhaustion. Use NullPool for SQLite and retain higher pool limits (pool_size=20, max_overflow=40) for Postgres.
Paragon SummaryThis pull request review identified 1 issue across 1 category in 2 files. The review analyzed code changes, potential bugs, security vulnerabilities, performance issues, and code quality concerns using automated analysis tools. This PR fixes a connection pool exhaustion issue by consolidating two separate SQLAlchemy engine instances into a single shared engine and increasing pool limits, eliminating the Key changes:
Confidence score: 5/5
2 files reviewed, 1 comment Severity breakdown: Low: 1 Tip: |
| import uuid | ||
|
|
||
| from transformerlab.db.constants import DATABASE_URL | ||
| from transformerlab.db.session import async_engine, async_session as AsyncSessionLocal |
There was a problem hiding this comment.
Bug: async_engine is imported but never used in user_model
async_engine is imported but never used in user_model.py. This adds unnecessary coupling and dead code. Remove the unused import.
View Details
Location: api/transformerlab/shared/models/user_model.py (lines 11)
Analysis
async_engine is imported but never used in user_model.py
| What fails | async_engine import is unused, adding unnecessary dependency coupling |
| Result | Code compiles with dead import that increases coupling between modules |
| Expected | Import should only include what is used (async_session as AsyncSessionLocal) |
| Impact | Low - adds unnecessary import coupling but no runtime impact |
How to reproduce
Check user_model.py - async_engine is imported but not referenced anywhere in the visible codePatch Details
-from transformerlab.db.session import async_engine, async_session as AsyncSessionLocal
+from transformerlab.db.session import async_session as AsyncSessionLocalAI Fix Prompt
Fix this issue: async_engine is imported but never used in user_model.py. This adds unnecessary coupling and dead code. Remove the unused import.
Location: api/transformerlab/shared/models/user_model.py (lines 11)
Problem: async_engine import is unused, adding unnecessary dependency coupling
Current behavior: Code compiles with dead import that increases coupling between modules
Expected: Import should only include what is used (async_session as AsyncSessionLocal)
Steps to reproduce: Check user_model.py - async_engine is imported but not referenced anywhere in the visible code
Provide a code fix.
Tip: Reply with @paragon-run to automatically fix this issue
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Problem
QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30.00The app had two separate
create_async_engine()calls against the same database — one indb/session.pyand another inshared/models/user_model.py— each with SQLAlchemy's default pool settings (pool_size=5,max_overflow=10). Under concurrent load, both pools would exhaust their connections.Fix
user_model.pynow imports and reuses the engine and session factory fromdb/session.pyinstead of creating its own.pool_size=20,max_overflow=40,pool_timeout=60on the shared engine.Testing
test_create_teamunrelated to this change).