Repository navigation
Recover a stalled profile writer without restarting Orca - #25319
AmethystLiang wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Initial review of the recovery layer stacked on #25318 — one commit (493ac55e0c) over unable-to-save-profile, 16 files.
- Durable operation identity:
profile_state_meta.last_write_operationrecords${connectionToken}:${requestId}in the same SQLite transaction as the revision bump; no-op writes record nothing. Centralized inwriteProfileStateRevision/readProfileStateRevisionOperation. - Readmission fence:
assertProfileStateRevisionOnDiskadoptsrevision + 1only when disk carries the interrupted request's id, threaded throughinitializeFromRevisionand the worker entry. - Supervisor:
ProfileStateWriterSupervisorreplaces a timed-out or exited worker after the old thread exits — adopting a proven commit, replaying at the acknowledged revision, and refusing (alerting once) on conflict, unconfirmed exit, start failure, closing, and more than 3 attempts per 10 minutes. - Wiring & diagnostics: the connection exposes
admitted/faulted/waitForExitand captures the interrupted operation on fault; the worker authority delegates to the supervisor; recovery breadcrumbs are payload-free. - Tests: new
profile-state-writer-recovery.test.ts(real bundled worker under a fault-injection wrapper) andprofile-state-write-operation.test.ts.
I traced the adopt-vs-replay predicate under concurrent writers, no-op writes, stale keys, multiple recoveries per supervisor, reads vs writes, and the committed computation, and traced close / abort / stopAdmission / pauseForMaintenance against an in-flight replace. Both hold: committed === true requires the fence match, the revision is monotonic with a CAS inside BEGIN IMMEDIATE, the per-connection UUID token makes the id collision-free, closing is latch-once, the install is in the same synchronous continuation as the post-ready closing check, and every await is deadline-bounded.
ℹ️ Nitpicks
- The committed-during-closing branch (
profile-state-writer-supervisor.ts:223-228) — whereclose()lands after a replacement has already adopted the interrupted write — has no test. The fixture'sstartDelayMs+hangWriteplan covers only the non-committed closing refusal, so this success-without-install path is unpinned.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
493ac55 to
109a752
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental review of the follow-up commit 109a7520 (Make recovery admission regression deterministic) on top of the recovery layer. The branch was rebased, so the net delta since the prior review is this test-only commit — no production code changed.
- Deterministic recovery-admission test: added a
startGate(SharedArrayBuffer) to the fault-injection fixture so a replacement worker blocks before its entry runs, lettingshares one replacement between the interrupted caller and the eager failure handlerassertassertWritable()while recovery is provably in flight instead of racing the replacement's initialization. - Strengthened queued-reply test: renamed and tightened the deadline test to assert exactly one worker instance and no recovery breadcrumbs, pinning the parent PR's drain-queued-reply-after-deadline behavior.
I traced the gate's Atomics.wait / Atomics.notify pairing across the worker boundary and the try/finally release path: the buffer is shared rather than cloned through workerData, the release runs even when the wait throws, and a worker that starts after release reads a non-zero gate and returns immediately. Ran both modified suites — profile-state-writer-recovery.test.ts (13 tests) and profile-state-write-operation.test.ts (3 tests) — all 16 pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
When the profile writer times out or its worker exits, Orca previously stopped saving until restart. Each committing write now records a unique operation id in the same SQLite transaction as its revision, so a replacement writer can prove whether an interrupted write committed. A supervisor in the worker authority replaces a timed-out or exited worker only after the old thread has exited, at the last acknowledged revision. It adopts a commit proven to be ours, replays a command when disk is still at the acknowledged revision, and refuses conflicts, unconfirmed exits, replacement start failures, closing, and more than three attempts in ten minutes, alerting once. Recovery start, success, and refusal leave sanitized durable breadcrumbs.
109a752 to
4660353
Compare
|
Closing in favor of the approach merged in #26447. Slow profile writes now produce a warning and remain pending until the worker replies; elapsed time alone no longer faults or replaces the writer. This removes the timeout failure path that motivated this recovery PR, so we are not proceeding with its timeout-based replacement and replay design. This PR also adds recovery after a real worker exit, which #26447 does not implement. That remains a separate potential follow-up: if we pursue it, it should be scoped to actual exits and adapted to the current warning-only save path, preserving proof of worker exit and safe commit adoption/replay. Closing this PR does not mean automatic recovery after real exits has shipped. |
|
Source-owner clarification for the remaining revision-conflict boundary, following your closure note and #26447. We verified that #26447 is merged and addresses slow-save warnings, not adoption of an intervening foreign revision. At main Is there an existing successor PR or a supported public, non-destructive readmission/reconciliation entrypoint for a live stale writer? The required boundary is preservation of active terminals and dirty foreign domains, reconciliation of an uncertain prior write before any replay, and continued exact revision fencing. We will not reset an observed revision, rewrite the profile database, patch an installed package, restart active PTYs, or replay historical pending automation runs. Our source-only automation preflush proposal prevents creation of another pending occurrence after a known persistence conflict, but deliberately does not claim readmission or global writer recovery. If live safe readmission is not supported, an explicit source-owner refusal/locator would let us keep this boundary held rather than infer an installation route from successful CI. No timeout-based worker replacement or replay is requested here. |

ELI5
When Orca's save helper stops responding, saving can recover without restarting Orca. Before retrying a save, the replacement checks whether that exact save already reached the database. If it cannot establish a safe outcome, it stops and reports the failure once.
What Changed
Why
A revision increase alone cannot prove whose save committed: another participant may have written to the profile. An operation ID recorded atomically with the revision supplies that proof. Rewriting a complete snapshot could overwrite someone else's changes, and content hashes cannot identify every supported operation.
The parent PR lets queued replies arrive before declaring a timeout, preventing healthy workers from unnecessarily consuming the recovery budget. Its close path also retains ownership until worker exit is confirmed.
Linked Issue
N/A — internal report; no existing linked issue.
Visual Proof
N/A — successful recovery has no UI surface. Refused recovery reuses the existing alert. Validation below exercises the runtime and database; a rendered user-flow demonstration has not been performed.
Testing
Real-worker recovery tests cover replay of an uncommitted write, adoption after a lost acknowledgment, foreign writes, shared recovery, idle exits, failed replacement, the retry limit, close during recovery, maintenance, queued edits, durability waiters, and saving a terminal binding afterward.
Operation-ID tests cover atomic commit recording, no-op behavior, matching adoption, and foreign-revision rejection.
119 targeted tests across 13 files pass on the rebased branch. The first combined run exposed a timing assumption in the admission test; holding replacement initialization at a shared-memory gate fixes the test, and the recovery suite passes on rerun. The queued-reply test now also asserts one worker and no recovery.
pnpm tc:node, changed-code quality, lint/format checks, andgit diff --checkpass.Inherited real Electron regression: four stalls beyond the save deadline followed by another save, with one worker and no failure alerts. The production 30-second version passed locally on macOS before restacking; the two-second version is included in the rebased validation and Linux/Windows CI.
Local execution: macOS. CI typecheck and static analysis pass. The persistence matrix has passed on macOS and Linux (x64 and ARM) and Windows x64; These results precede the final restack over the parent's headless-test-routing fix. Both recovery commits are unchanged by that restack (
git range-diffmatches); full CI is rerunning on the latest head.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Focus on replay versus adoption, refusing foreign revisions, and close during recovery. An unresolved write remains unresolved at quit or profile switch; closing does not show a failure alert.
Agent skill upstream boundary
Notes
One extra metadata upsert per committing write; no additional process on successful saves. Older builds ignore the new metadata key, and a foreign commit cannot match the new worker's operation ID. No schema-version or wire-protocol change. The execution host continues to own persistence for SSH/headless use. This does not establish the cause of the original main-process stall.
Checklist