Repository navigation
fix(gateway): bound all-agent usage cache concurrency - #101589
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 1:27 PM ET / 17:27 UTC. Summary PR surface: Source +7, Tests +57. Total +64 across 2 files. Reproducibility: yes. at source level rather than a live outage replay. Origin/main and v2026.6.11 call Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the bounded gateway Do we have a high-confidence way to reproduce the issue? Yes, at source level rather than a live outage replay. Origin/main and v2026.6.11 call Is this the best way to solve the issue? Yes. The gateway handler owns the all-agent fan-out, and reusing the existing bounded concurrency helper matches the sibling AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b88f80940add. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +57. Total +64 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
…e starvation Replace raw Promise.all in loadAllAgentCostUsageSummary with runTasksWithConcurrency (limit=12), matching the sibling sessions.usage pattern. Unbounded concurrent usage-cost cache reads saturated the SQLite connection pool for deployments with 100+ agents, causing SQLITE_BUSY timeouts or gateway memory crashes. Fixes openclaw#101552
0dace0f to
062a5ef
Compare
|
Land-ready proof for exact head
Source inspection corrected the issue's mechanism: |
|
Merged via squash.
|
* fix(gateway): bound all-agent usage.cost concurrency to prevent SQLite starvation Replace raw Promise.all in loadAllAgentCostUsageSummary with runTasksWithConcurrency (limit=12), matching the sibling sessions.usage pattern. Unbounded concurrent usage-cost cache reads saturated the SQLite connection pool for deployments with 100+ agents, causing SQLITE_BUSY timeouts or gateway memory crashes. Fixes openclaw#101552 * fix(gateway): share usage cache concurrency cap --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
usage.costwithagentScope: "all"started one usage-cost cache load forevery configured agent through an unbounded
Promise.all. Large multi-agentdeployments could therefore multiply cache reads, transcript enumeration, and
background refresh work at once.
Fixes #101552.
Why This Change Was Made
sessions.usagepath already bounds the same class of per-agentusage-cache work.
USAGE_AGENT_LOAD_CONCURRENCY = 12.errorMode: "stop"plus rethrowingfirstErrorpreserves the originalPromise.allfailure behavior.all-agent fan-out.
The issue originally described SQLite connection-pool starvation. Direct
inspection of
loadCostUsageSummaryFromCacheshows filesystem-backed usagecache and transcript work instead, so this PR intentionally uses the narrower
source-backed wording.
User Impact
same aggregation result.
totals.
Evidence
node scripts/run-vitest.mjs src/gateway/server-methods/usage.test.ts(2 files, 62 tests passed)
node scripts/run-oxlint.mjs src/gateway/server-methods/usage.ts src/gateway/server-methods/usage.test.ts./node_modules/.bin/oxfmt --check src/gateway/server-methods/usage.ts src/gateway/server-methods/usage.test.tsgit diff --checktbx_01kwyrv80bmm6hxj5xxyyatsdb:pnpm check:changedpassedThe regression test uses a deterministic promise gate. It proves that only 12
of 13 configured agent loads start before release, then verifies all 13 totals
are aggregated after the gate opens.