fix(perf): evict approve-lock leak, index auth_requests, reuse shared httpx client (#660) - #752
Conversation
… httpx client (#660) - Evict per-request lock from _approve_locks after terminal decision so the dict does not grow unbounded over the process lifetime (try/finally pop in approve_auth_request handler). - Add idx_auth_requests_status and idx_auth_requests_identity indexes to auth_requests SCHEMA so list_pending and count_pending_for queries use indexed scans. - Replace five inline httpx.AsyncClient context managers in user_memory routes with the shared request.app.state.http_client; pass timeout per-call. Update four affected tests to inject mock via app.state.http_client instead of patching the constructor.
|
Warning Review limit reached
More reviews will be available in 2 minutes. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Three audit safe-cleanups with zero runtime-behavior change:
asyncio.Lockfrom_approve_locksin atry/finallyblock afterapprove_auth_requestreaches a terminal decision. Without this the dict grows for the process lifetime (one entry per uniquerequest_idever approved).idx_auth_requests_statusandidx_auth_requests_identityto theauth_requestsSCHEMA.list_pendingandcount_pending_forpreviously did full-table scans. TheIF NOT EXISTSguard meansBaseStore.init()applies them idempotently on next startup with no migration step.async with httpx.AsyncClient(timeout=...)blocks inuser_memoryroutes withrequest.app.state.http_client(the shared client already owned by the app). Timeout is forwarded on each individual.get/.postcall. Affected tests updated to inject mocks viaapp.state.http_client = mock_clientinstead of patching the constructor.[label: perf, audit]