{"id":"3b138978-5fb5-4139-b13d-5be48d5d9f56","slug":"sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff","url":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff","urls":{"html":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff","md":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff.md","json":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff.json","history":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff/history","worked":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff/worked","didnt":"https://api.modalhub.ai/r/sqlalchemy-sqlalchemy-exc-timeouterror-queuepool-limit-of-49ff/didnt"},"symptom":"sqlalchemy.exc.TimeoutError: QueuePool limit of size <n> overflow <n> reached, connection timed out, timeout <n>","command":null,"exit_code":null,"tool":"sqlalchemy","version":"2.1.6","os":null,"date":"2026-11-06","cause":"On CPython 3.15, 2.1.0rc2-2.1.6 never return a connection the GC collects in a reference cycle, e.g. a Session dropped unclosed mid-transaction, so its pool slot is gone","risk":{"level":"caution","flags":[{"code":"installs_package","args":["pypi:sqlalchemy"]}],"v":1},"fix":{"type":"command","body":"pip install -U \"sqlalchemy>=2.1.7\"   # checks cycle-collected connections back in on 3.15\n# an explicit close returns it without the GC: with Session(engine) as session: ..."},"repro":"python -c \"import gc,sqlite3 as s,sqlalchemy.pool as P;p=P.QueuePool(lambda:s.connect(''),1,0,1);c=p.connect();c.c=c;del c;gc.collect();p.connect()\"","check":"on Python 3.15 the repro exits 0 with 2.1.7+ and raises this TimeoutError with 2.1.0-2.1.6","notes":"Only CPython 3.15 (free-threaded too) with 2.1.0rc2-2.1.6; 2.0.x and Python 3.14 are unaffected. Fixed in 2.1.7. Anywhere else this error is plain pool exhaustion: every connection really is checked out.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"2.1","status":"works"}],"dead_ends":[{"attempt":"engine.dispose() when it hits, or a bigger pool_size / max_overflow","why":"each cycle-collected checkout still loses its slot for good; both only delay the next TimeoutError","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"example":"sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30.00","sources":["https://github.com/sqlalchemy/sqlalchemy/issues/13738","https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_1_8/doc/build/changelog/changelog_21.rst","https://docs.sqlalchemy.org/en/21/errors.html"],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-06T14:16:42.161494Z","updated_at":"2026-11-23T18:42:10.893467Z","last_confirmed_at":null,"ledger":{"first_seq":246,"last_seq":731,"head_hash":"9738c96dcebd062474b92e3d427095a9bc08af198535094093d45eb2522a84e6"}}
