Repository navigation
fix(gateway): bound usage.cost all-agent fan-out concurrency to prevent SQLite starvation - #101578
chenxiaoyu209 wants to merge 1 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this PR now contains the right narrow gateway fix, but an open proof-positive sibling PR owns the same linked issue with the same bounded-concurrency approach and stronger maintainer-ready evidence. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this duplicate branch and continue review on So I’m closing this here and keeping the remaining discussion on #101589, #101552, and #101581. Review detailsBest possible solution: Close this duplicate branch and continue review on Do we have a high-confidence way to reproduce the issue? Yes for source-level reproduction: current main and Is this the best way to solve the issue? No as the best landing path. The patch shape is correct, but the same linked issue is already owned by a proof-positive open sibling PR with equivalent bounded-concurrency behavior. Security review: Security review cleared: No security or supply-chain concern was found; the diff only changes gateway usage aggregation and a focused test, with no dependencies, workflows, permissions, downloads, package metadata, or secret handling. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 2ba622ca3019. |
9e57e70 to
0df4412
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…nt SQLite starvation Replace unbounded Promise.all in loadAllAgentCostUsageSummary with runTasksWithConcurrency capped at SESSIONS_USAGE_AGENT_LOAD_CONCURRENCY (12), matching the existing sessions.usage pattern in the same module. Fixes #101552 Co-Authored-By: Claude <[email protected]>
a56fe4e to
b8c4f7f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Thanks @chenxiaoyu209. This is now superseded by the canonical repair in #101589, landed as e5c2247. Your version identified the same valid all-agent fan-out problem and reused the existing limit. The landed version keeps that useful direction, shares one generic usage-cache concurrency constant across both sibling handlers, preserves the original all-or-nothing error behavior, and adds a deterministic 13-agent regression without timer-based scheduling assumptions. Direct source inspection also showed filesystem-backed usage-cache and transcript work rather than SQLite connection-pool starvation, so the canonical PR corrected that mechanism in its title and evidence. Closing this duplicate now that the complete fix is on |
What Problem This Solves
Fixes #101552
loadAllAgentCostUsageSummaryfans outloadCostUsageSummaryFromCachecalls for every configured agent through an unboundedPromise.all. With 100+ agents this saturates the SQLite connection pool, causingSQLITE_BUSYtimeouts or memory spikes that crash the gateway process.Why This Change Was Made
The sibling
sessions.usagepath already usesrunTasksWithConcurrencywithSESSIONS_USAGE_AGENT_LOAD_CONCURRENCY = 12to bound per-agent cache-load fan-out. This change applies the same pattern tousage.cost, reusing the same helper and concurrency limit that are already imported and proven in the same module.User Impact
Promise.allsilent rejection toerrorMode: "stop"fail-fast, consistent withsessions.usageEvidence
pnpm test src/gateway/server-methods/usage.test.ts— 62 tests pass (2 files), including new concurrency-cap regression testpnpm test src/gateway/server-methods/usage.sessions-usage.test.ts— 42 tests pass, no regression🤖 Generated with Claude Code