Repository navigation
fix: retry temporary database capacity failures during agent startup - #173994
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: needs maintainer review before merge. What this changesRetry temporary SQLite opening-capacity refusals within the existing bounded agent-startup retry policy. Example: An agent encounters opening-capacity refusal while 64 real SQLite stores occupy the broker, then capacity becomes available.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a confirmed startup-recovery failure still present on current main, with convincing exact-head Gateway evidence and no identified correctness defect. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway startup admission coordinates deferred database opening, migration, and publication; broker refusals enter this owner, which either admits the agent or records a readiness failure. flowchart TD
A[Gateway startup] --> B[Startup admission owner]
B --> C[SQLite database opening]
C --> D[Bounded opening retry]
D --> C
C --> E[Migration]
E --> F[Agent publication]
F --> G[Conversation available]
Technical reviewBest possible solution: Keep recovery in the existing startup owner, retaining bounded opening retries and separate migration and publication phases. Do we have a high-confidence way to reproduce the issue? The supplied independent built-Gateway baseline reproduces terminal opening-capacity degradation twice; the affected startup source is unchanged on fetched main, and this review ran no target code. Is this the best way to solve the issue? The scoped fix uses the existing preparation owner, releases opening permits before backoff, rechecks deletion and file identity, and avoids replaying completed migration or publication. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4d2a9f8bb4c4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +8, Docs +6. Total +14 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 30, 2026, 6:05 PM ET / 22:05 UTC (Revision 9). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Ran this head (205f57e) on our 810-agent production copy against its parent (387ebd6): 4 vCPU / 16 GB, Node 24.21, The retry works. In the boot where deferred preparation ran at fleet scale, 1,038 opens were rejected with The next gate now fails the same way: 136 agents stayed degraded until restart with Happy to rerun on a revision. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Independent current-main startup recovery proof for exact head Refreshed the contributor's original commits on main Actual capacity conditionThis PR handles SQLite broker store/open-input capacity, not disk-full errors. A task-owned plugin uses the public SQLite SDK to open real databases and hold real broker operations. 64 stores occupy the actual unchanged broker limit; the next open produces the production The setup first completes a real seed agent turn, stops that Gateway, and removes one index from the owned offline target database, following the existing unsealed-fleet startup regression. This requires actual writable startup repair instead of letting early read admission warm the target owner before pressure. The pressure is released only after observing the target's production opening outcome, not on a timer. A safety deadline would fail the proof. Observed runs
Configuration and workspace sentinel hashes remain unchanged in all five runs. Independent read-only SQLite reads verify transcript roles after shutdown. Candidate readiness succeeds after release. No system clock changes, external model-provider credentials, live channel, physical disk-capacity or new upgrade claim. Representative captured production output: Checks and scope
The older macOS upgrade evidence in the prior description remains historical; the results above are the new current-main/exact-head Linux startup proof. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…penclaw#173994) fix(gateway): recover when SQLite capacity frees up during startup If SQLite broker capacity was exhausted while the Gateway started, startup gave up and the Gateway stayed unavailable even after capacity was freed, until it was restarted by hand. Startup now retries within the existing startup flow, so the same Gateway process recovers once capacity is available. There is no new budget or configuration. Evidence: built Gateways with real SQLite broker capacity exhausted and then released. Main stayed unavailable after the release (twice). With this change it recovered in the same process and continued the saved conversation (twice). A normal startup control passed. Config and workspace hashes and session identity were preserved. Details: openclaw#173994 (comment). Thanks @McgAtom. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #162497
What Problem This Solves
Agents can remain degraded after a temporary SQLite broker-capacity refusal during Gateway startup, even after capacity is released. This PR lets their database preparation recover during that same startup.
User Impact
An affected agent can complete startup and continue its existing conversation without another Gateway restart. Persistent pressure and genuine database failures still fail visibly. No configuration, schema or storage-format change is required.
Why This Change Was Made
The existing startup preparation owner retries canonical overloaded opens within its bounded, abortable policy. Opening lock and capacity refusals share one four-attempt budget, with deletion/file-identity checks before retry and opening permits released before backoff. An opening retry does not repeat migration or publication. Migration locks retain their existing separate phase retry and opened borrower.
The contributor's commits are retained and refreshed on current main, preserving upstream early-read admission and restart-input recovery. This is only the recovery fix: it does not include the permanent resource-budget feature proposed in #182165 or change any broker limit.
Evidence
Independent current-main and exact-head built-Gateway proof.
65acdfd629e3555f3c876e3fe887d548633e1863and candidate94e2440d241d80d750ece96c989c136fa40725c3builds in secretless Linux arm64 Docker, Node 24.22.1.This is real broker pressure through a public-SDK plugin, not a fabricated exception, replaced startup callback or filesystem-full condition. The baseline is a full main build, not an owner-file substitution. No live-provider, live-channel or new upgrade claim is made. Candidate 2's functional proof passed but its cleanup driver falsely counted two defunct processes; independent follow-up confirmed no live proof children, and the corrected census completed the normal control successfully. Full details and the limitation are in the linked evidence.
Simplification keeps one preparation owner and reuses its existing retry policy without new state, exported helper or alternate recovery path.
Merge Danger
Two-way door: reverting restores the former opening-refusal behavior; there is no migration or persisted contract to undo. Blast radius is deferred agent database startup preparation under lock/capacity pressure. An incorrect retry classification could delay a genuine failure or repeat unsafe work; retries remain bounded, abortable and restricted to opening capacity refusals, with existing lifecycle/identity checks and separate migration/publication ownership.