Repository navigation
perf(auth): keep active database readers warm with idle expiry - #150524
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 16, 2026, 11:42 PM ET / September 17, 2026, 03:42 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR retains up to 64 auth database readers, expires idle connections after 30 minutes, preserves useful readers when replacement opens fail, and adds focused lifecycle coverage. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful: current main and v2026.9.4 retain the premature-eviction behavior. No actionable introduced defect was found. The earlier migration-proof blocker does not apply because this patch changes connection lifecycle without changing persistent storage contracts. Priority: P2 Review scores
Verification
How this fits togetherAuth profile storage reads saved credentials and scheduling state from agent databases. Its reader pool reuses SQLite connections while leaving row interpretation, credential ownership checks, and writes with their existing owners. flowchart TD
A[Auth profile read] --> B[Path-keyed reader pool]
B --> C{Reusable reader?}
C -->|Yes| D[Refresh idle timer]
C -->|No| E[Open and validate candidate]
E -->|Valid| F[Admit within capacity]
D --> G[Read current committed rows]
F --> G
B --> H[Idle or explicit cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +69, Tests +292, Other -1. Total +360 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep bounded reader reuse and failure-safe admission in the pool owner while preserving current-row reads and immediate explicit invalidation. Do we have a high-confidence way to reproduce the issue? Yes, from source: fill main's eight-reader pool, then inspect a missing database; eviction occurs before the failed open. This review did not execute that scenario. Is this the best way to solve the issue? Yes. The patch repairs admission in the existing pool, preserves its callers and storage semantics, and bounds the larger cache with idle expiry. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9a4468148bc0. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
46cb0ee to
a44bb28
Compare
|
Merged via squash.
|
…law#150524) * fix(auth): preserve pooled readers when database opens fail * fix(auth): use owned busy timeout setup for pooled readers * perf(auth): retain readers with thirty-minute idle expiry * test(auth): describe required reader lifecycle values
Related: #145579.
What Problem This Solves
Auth reads across many active agents repeatedly reopen SQLite databases after the eight-reader pool fills. A failed open for a missing database also evicts a useful reader before there is a replacement.
User Impact
Keep up to 64 auth readers available and close each connection after 30 minutes without use. Missing or unreadable candidates preserve existing readers. The measured 32-agent workload retains 24 additional file descriptors while warm; explicit cleanup releases them all. Reads still observe external committed changes and runtime snapshot invalidation. No configuration, schema, persisted data or credential policy changes.
Why This Change Was Made
Keep admission and native-handle custody in one pool owner. Validate a new reader before eviction, retain failed-close handles for cleanup, and block further uncached admission while an unadmitted handle cannot close. The bound is 64 admitted readers plus one transient or failed candidate.
Refresh each reader's existing idle timer on reuse. Timers are unreferenced and use the existing SQLite maintenance context so they do not retain a request context. A stale callback cannot close a replacement reader; failed idle closes retain custody, retry at the same interval, and preserve exit cleanup. Explicit closure still takes effect immediately when native close succeeds.
Evidence
62f1666ccc6f6912ae3ba779470d7aa5de67fa78, including types and architecture checks. Local type preparation stopped before compilation at the maintained nested-checkout dependency-isolation guard. All diff-caused CI findings were repaired and verified. Final combined-main Gateway load follows landing.