Repository navigation
fix(infra): attribute SQLite worker exits instead of defaulting every one to "exit" - #163907
wangmiao0668000666 wants to merge 1 commit into
Conversation
… one to "exit" Record the owner-declared retirement reason before native exit so the stability bundle can tell an idle drain from a crash, and log an unclaimed non-zero exit code once instead of settling silently. - retire() marks "closed" before terminate() - error/messageerror mark "failure" and log the cause once - exit forwards the owner reason; an unclaimed non-zero code is "failure" and is logged with its code Fixes openclaw#163150. Co-Authored-By: Claude Code <[email protected]>
|
🦞👀 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. Reviewed October 2, 2026, 9:03 PM ET / October 3, 2026, 01:03 UTC. ClawSweeper reviewWhat this changesThe PR adds SQLite worker retirement reasons and failure logging, with two mocked lifecycle regressions. Merge readiness⛔ Blocked before merge - 3 items remain The diagnostics gap remains on current main, but this patch does not repair retirement counters because it forwards attribution after the registry has removed the worker. Another open PR covers the same problem; neither implementation has merged. Priority: P2 Review scores
Verification
How this fits togetherThe SQLite worker broker runs database operations outside the Gateway main thread and owns worker shutdown. Its lifecycle events feed a shared registry that publishes worker retirement counters in diagnostics and stability bundles. flowchart TD
A[Database operations] --> B[SQLite worker broker]
B --> C[Worker lifecycle]
C --> D[Requested shutdown or failure]
D --> E[Worker accounting registry]
E --> F[Stability bundle counters]
D --> G[Gateway logs]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +50, Tests +81. Total +131 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one shared accounting owner, deliver retirement intent before its exit accounting runs, and validate actual counters and once-only logs without changing database cleanup semantics. Do we have a high-confidence way to reproduce the issue? Yes, from source: registry registration order guarantees that its exit accounting runs before the newly added broker attribution call. No runtime reproduction was executed. Is this the best way to solve the issue? No, the current forwarding point is too late; the existing registry must receive intent before accounting, and regressions should assert real counter changes rather than mocked calls. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 688f68e7779c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Closing in favor of #163377, which covers the same issue #163150 with the ordering-correct implementation. The P2 finding on this PR is correct: #163377 already implements what that finding prescribes: intent marked on the error/messageerror events and before |
What Problem This Solves
Fixes: SQLite store worker retirements are always recorded as the fallback reason
exit, so the stability bundle cannot distinguish an idle drain from a deliberate terminate, anerror/messageerrorevent, or a heap-limit kill.workerLifecycleforsqlite-store.worker.jsreportsretired: [{reason: "exit", count: N}]even when the broker retired the slot on purpose, and the gateway logs contain no exit code or cause.User Impact
No runtime behavior changes. Operators triaging SQLite worker churn (
#159638) or "lost its native owner" failures (#163151) can now see why each worker exited, and a genuine crash logs its exit code once instead of being silently absorbed byfail().Why This Change Was Made
worker-task-poolalready attributes its own retirements by callingmarkWorkerRetirementwithclosed,cancelled, orfailure. The SQLite broker'screateSlotimported onlycreateCpuTrackedWorkerand never marked anything, soforgetWorkeralways fell back to"exit"(src/infra/worker-cpu.ts:132).This change makes the lifecycle owner declare the cause at each exit path:
retire()): markclosedbeforeterminate(), so a normal idle/eviction retirement stops reading as a crash.error/messageerror: markfailureand log the message once (previously the cause reachedfail()with no log line).exithandler: forward the owner-declared reason; an unclaimed non-zero exit is recorded asfailureand logged once with its code. A clean unclaimed exit keeps the existingexitlabel.The
Slottype gains an optionalretirementReasonfield (the first claim wins), mirroringWorkerSource.retirementReasoninworker-cpu.ts. The marks are recorded before native exit so the owner's intent is preserved, matching the existingmarkWorkerRetirementcontract ("only confirmed native exit increments retirement").Evidence
attributes an owner-initiated retirement instead of the default exit reason: a slot retired throughlifecycle.retire()now forwardsclosedtomarkWorkerRetirement, not the defaultexit.records an unclaimed non-zero exit as a failure with its code logged: an unclaimedexit(134)forwardsfailureand emitsSQLite worker exited unexpectedly with code 134through theinfra/sqlite-workerlogger.node scripts/run-vitest.mjs src/infra/sqlite-worker-broker-lifecycle.test.ts— 8 passed (6 existing lifecycle cases plus the 2 new ones). Both new cases fail on the pre-change source (the existingexithandler called neithermarkWorkerRetirementnor a logger).node scripts/check-changed.mjsselected lanescore production+core testfor the three changed files pass; the only unrelated failure is the line-cap ratchet choking on an untracked scratch directory in the local tree (none of the changed files appear inconfig/max-lines-baseline.txt).node --import ./scripts/tsx.mjs scripts/check-line-cap-ratchet.mts --base origin/mainexits 0 for this change.Scope
Diagnostics only: no stored-data, schema, retention, or recovery change; no user-visible behavior change. The exit code and reason are additive metadata on the existing stability-bundle retirement accounting.
Fixes #163150.