You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dependencies): double-checked locking pattern is a data race under free-threaded Python 3.13+ (PEP 703) #296
The singleton initialization pattern in backend/app/api/dependencies.py uses double-checked locking: check _cache is None, acquire lock, check again, create. This is safe under CPython's GIL but becomes a data race under Python 3.13+ free-threaded mode (PEP 703, nogil). Two threads can both pass the outer None check and construct duplicate SQLAlchemy engines, leaking connection pools.
Fix
backend/app/api/dependencies.py: move the singleton initialization to module level (eager init at import time) or initialize inside the lock without the outer None check. This removes the TOCTOU window entirely.
Impact
Under free-threaded Python 3.13+, multiple competing SQLAlchemy engine instances are created, each with their own connection pool, causing pool exhaustion and connection leaks under concurrent startup.
Activity
fix(sprint-r4): root-cause fixes for all 17 bugs from code review rou…
piyushmakhija28 commentedon Jun 21, 2026
Fixed in PR #280 (Sprint R3/R4: fix(sprint-r3): root-cause fixes for all 39 bugs from code review round 3 + Sprint R4 round 4)