Skip to content

fix: QueuePool hygiene for job-poll auth (mainline) - #228

Merged
suguanYang merged 4 commits into
mainfrom
fix/wangbinqi/queuepool-job-poll-hygiene
Jul 25, 2026
Merged

fix: QueuePool hygiene for job-poll auth (mainline)#228
suguanYang merged 4 commits into
mainfrom
fix/wangbinqi/queuepool-job-poll-hygiene

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

  • Stop nested QueuePool checkouts on job-poll auth by reusing the request AsyncSession for tier lookup and API-key last_used updates (Redis SET NX debounce).
  • Wire async engine to DB_POOL_SIZE / DB_MAX_OVERFLOW defaults of 50/50 so legal poll bursts no longer exhaust the per-process pool.
  • Dual delivery: this is the mainline PR into main; a sibling hotfix targets prod cut v2026.06.18.2 via release/v2026.06.18.2. No rate-limit policy changes.

Test plan

  • Unit tests: apps/api/tests/unit/test_job_poll_session_hygiene.py and shared/tests/test_database_pool_config.py
  • Confirm job poll / auth paths hold a single session (no nested get_db_context for tier + last_used)
  • Confirm pool defaults/env read as 50/50; no change to rate-limit admission behavior
  • Smoke: concurrent job-status polls under load do not hit QueuePool timeout

Made with Cursor

suguanYang and others added 2 commits July 25, 2026 20:14
Reuse the request AsyncSession for tier lookup and API-key last_used
updates (with Redis debounce), and wire the async engine to
DB_POOL_SIZE/MAX_OVERFLOW defaults of 50/50 so legal poll bursts no
longer exhaust the per-process pool via nested get_db_context holds.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use Redis SET NX for last-used debounce, require the request session in
resolve_current_user, and avoid double-commit when TierService owns the session.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/api/app/services/auth/api_key_authentication_service.py Fixed
suguanYang and others added 2 commits July 25, 2026 20:59
Explain the best-effort rollback swallow for CodeQL, narrow pool
pressure logging to QueuePool for pyright, and stop unit tests from
shadowing the worker `app` package during shared pytest collection.

Co-authored-by: Cursor <cursoragent@cursor.com>
Harden worker contract eviction to drop deepest API-shadowed modules
first, and make job-poll unit tests reassert the API import root then
clear cached API app modules so shared pytest runs stay green.

Co-authored-by: Cursor <cursoragent@cursor.com>
@suguanYang
suguanYang merged commit 7282a01 into main Jul 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants