Repository navigation
fix: recover large session histories without worker memory failure - #182073
diregoblin wants to merge 1 commit into
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 real behavior proof before merge. What this changesStreams transcript events through the existing atomic recovery transaction instead of retaining whole-history arrays. Example: Recover a tombstoned SQLite session containing 600 compressed body events that decode to more than 512 MiB.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain This PR addresses a current, source-backed recovery defect with a focused streaming fix; the new assertion also introduces a narrow, repairable CI failure. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherRestart recovery sends a guarded command to the agent database worker, which clones the transcript and atomically records the successor and source link before the host publishes identity changes. flowchart LR
A[Recovery request] --> B[Host authority and admission]
B --> C[Agent database worker]
C --> D[Scoped transcript iterator]
D --> E[Bounded transcript append]
E --> F[Atomic successor and source commit]
F --> G[Host identity publication]
Technical reviewBest possible solution: Keep the scoped streaming reader and existing atomic append owner, restoring the original typed JSON parse to satisfy the assertion ratchet. Do we have a high-confidence way to reproduce the issue? Current main visibly retains the complete decoded transcript, and the contributor reports an exact-base production-worker OOM regression; this read-only review did not execute it. Is this the best way to solve the issue? The smallest complete repair removes whole-history retention while preserving query admission, cursor cleanup, bounded appends, and atomic publication through existing owners. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b052b9736bca. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +21, Tests +94. Total +115 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 Reviewed October 23, 2026, 9:35 PM ET / October 24, 2026, 01:35 UTC. |
…story (#182091) Restart recovery now streams transcript events through the existing bounded append owner instead of holding the fully decoded history plus a filtered copy; the successor and its tombstone link still publish in one synchronous transaction, with no schema change. A 544 MiB transcript that previously hit ERR_WORKER_OUT_OF_MEMORY now recovers; ~100 MiB recovered in 8.5 s at 244 MiB peak worker heap. Fixes #182060. Supersedes #182073. Thanks @diregoblin. Co-authored-by: Pavel Zun <[email protected]>
|
Thank you @diregoblin for the fix and the measured report. We re-implemented this in #182091, now on main, with you credited as co-author. Restart recovery streams transcript events through the bounded append owner instead of holding the whole decoded history. Closing as superseded. |
…story (openclaw#182091) Restart recovery now streams transcript events through the existing bounded append owner instead of holding the fully decoded history plus a filtered copy; the successor and its tombstone link still publish in one synchronous transaction, with no schema change. A 544 MiB transcript that previously hit ERR_WORKER_OUT_OF_MEMORY now recovers; ~100 MiB recovered in 8.5 s at 244 MiB peak worker heap. Fixes openclaw#182060. Supersedes openclaw#182073. Thanks @diregoblin. Co-authored-by: Pavel Zun <[email protected]>
Closes #182060
What Problem This Solves
Fixes restart recovery failing with
ERR_WORKER_OUT_OF_MEMORYwhen a session has a large SQLite-backed history.User Impact
Users can recover the complete history without increasing the worker heap or truncating the conversation. Existing atomicity, lifecycle checks, and successor linking are preserved; no configuration or schema changes are required.
Why This Change Was Made
Recovery currently materializes every decoded event, then filters and spreads additional whole-history arrays. The canonical reader now supports scoped synchronous iteration; recovery passes a lazy replacement-header/body stream to the existing bounded append owner inside the same transaction. Existing array consumers retain their contract and share query, decoding, hot-snapshot admission, and cursor cleanup.
This removes recovery-wide decoded/filter/spread arrays, not the existing array API. Production delta is +68/-47 lines (net +21), with +94 test lines for the memory boundary and partial-write rollback. PostgreSQL buffering and the cost of an individual event are unchanged.
Evidence
ERR_WORKER_OUT_OF_MEMORYunder the default 512 MiB worker limit (60.162 s wall).OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/config/sessions/session-accessor.recovery.test.ts --maxWorkers=1(equivalent repository test wrapper; 56.996 s wall, about 23 s test time; large-history case 13.647 s). The actual worker heap boundary cannot be established by a parser mock. CI seconds are not yet available.The fixture is entirely synthetic. This is production-worker proof, not yet proof of recovery through a serving Gateway. Broader checks are left to PR CI.