Repository navigation
fix(workboard): stop SQLite descriptor leaks on plugin reload - #122146
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 7:48 PM ET / 23:48 UTC. ClawSweeper reviewWhat this changesThe PR gives each Workboard registration ownership of its SQLite connection, drains admitted operations before closing it, removes unowned fallback connections, and adds lifecycle regression tests. Merge readiness⛔ Blocked before merge - 3 items remain This remains a useful fix: current main and v2026.9.1 still discard Workboard's SQLite cleanup callback. No introduced blocking defect was found, and the packaged behavior proof is sufficient; independent verification of the cited native descriptor-retention explanation remains a reviewer-side limitation. Priority: P2 Review scores
Verification
How this fits togetherWorkboard is OpenClaw's local task board. Dashboard requests, agent tools, commands, and session events use its SQLite store; replacing the plugin registry must retire that store without interrupting admitted work or closing its successor. flowchart TD
A[Dashboard requests and agent tools] --> B[Registration-owned Workboard store]
C[Commands and session events] --> B
D[Plugin registry replacement] --> E[Stop new work and drain admitted operations]
B --> E
E --> F[Close retired SQLite connection]
D --> G[Independent successor store]
Decision needed
Why: The source repair and product observations support the fix, but this worker cannot complete the applicable upstream inspection because the cited sources are unreachable. Before merge
Agent review detailsSecurityNone. PR surfaceSource +75, Tests +274. Total +349 across 10 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one registration-owned lifetime that absorbs the existing mutation queue and change tracker, drains complete admitted operations, and closes only its retired SQLite connection without changing stored data or configuration. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main discards the factory cleanup callback, and repeated registry replacement is the supplied reproduction path. The captured packaged baseline supports that mechanism; this read-only review did not execute it. Is this the best way to solve the issue? Yes. Repairing connection ownership at registration and draining whole operations preserves compound requests while reusing existing host retirement; no competing configuration path or storage migration is needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 66fa0bd2be4f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review The semantic current-main port is published at |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Port the acquisition test from 0d830e9 (openclaw#136146). Preserve socket-close, server ownership, and selector assertions while joining disposable workers for intentionally retained raw acquisitions.
|
Thanks @NianJiuZst! Landed as 7baae61fa1f, preserving your primary credit and the original contribution's ancestry in the reviewed branch. Proof: The installed Gateway stayed alive through supported Workboard reloads, fresh card operations and repeated in-flight successor overlap. Each retired WAL descriptor disappeared; fresh stores and recorded request outcomes remained usable.
Validation: 413 Workboard/host/doctor tests, full changed checks, canonical package integrity and installed Gateway proof. The final test-only fixture port passed all 29 acquisition cases and its changed checks. Production/package inputs were unchanged, so the complete product proof was retained. Exact-head CI 33931014430 passed on 0b22be085f1. Fresh independent LandPR review passed all 11 passes at the required P0 threshold. The latest ClawSweeper source-access limitation was resolved by checking the exact Node/SQLite sources and supplying both complete files to that review; no proof or CI exception was used. The landed change contains only the ten Workboard files: production +286/-211 (net +75), tests +274. The acquisition fixture was already on main and adds no extra landed delta. Issue #121592 is closed. AI-assisted. |
…aw#122146) Closes openclaw#121592. Retain the Workboard SQLite factory's close callback and invoke it through the existing registry-retirement lifecycle. Drain admitted Gateway, tool and background operations before closing that registration's store. Keep session-only cleanup and successor stores usable. Reuse current registry eviction and command-drain ownership. Preserve native compare-and-swap methods and current-main keyed collection reads. No schema, retention or operator configuration changes. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #121592
What Problem This Solves
Fixes an issue where operators reloading Workboard would accumulate SQLite file descriptors in the running Gateway. The SQLite factory returned a close callback, but the Workboard store discarded it and registered no resource cleanup.
Why This Change Was Made
Workboard now retains that callback and connects each store to the existing registry-retirement lifecycle. Its store runtime joins admitted Gateway calls, tools, terminal hooks and background work before closing the old connection. New operations on a closed store fail explicitly. Session reset/delete does not close the process-wide store.
The existing mutation queue and change tracker now share that lifetime owner. Unowned Gateway/tool fallback stores are removed. Existing command draining, registry cache eviction, native compare-and-swap methods and request/lifecycle authority remain unchanged. Current-main keyed collection reads are preserved.
No schema, stored representation, retention or operator configuration changes.
User Impact
Normal Workboard reloads no longer grow descriptors linearly. Fresh stores still support create, read, update, comment, move and delete. An admitted start request can record its outcome after replacement without closing the live successor.
Evidence
Current candidate:
0b22be085f1dad5966a33349f0e582469ce1f622.Packaged product-tested head:
87a99e6e0fc161f202caf872aaf3cee13c55e047.Main baseline:
325426c75fc7303cae45880b835dcd28807af4a1.Integrated main:
f19b43e46f91c1788597264cb4cbc35e0a17f2ff.Real product proof used a normally enabled bundled Workboard in an installed package, in an isolated secretless Linux container on Node 24.20.0. The driver used the shipped CLI/Gateway methods,
config.getrevision hashes, supportedconfig.patchupdates and actual hot-reload completion. Only that Gateway PID's own Workboard database/WAL/shared-memory descriptors were measured.The in-flight input was a supported repository worktree setup script that waited for release, then exited 23. No model or channel credentials were needed. The same Gateway PID and process instance remained alive throughout every measurement.
Descriptor interpretation and retained failed attempt
An initial zero-total-descriptor assertion was incorrect for this topology. Prepared-model discovery holds a separate non-activated registry/store. SQLite deliberately retains and reuses database descriptors from closed connections while another connection holds POSIX locks; closing those descriptors directly would disturb that other connection.
This was verified with a separate native dependency experiment and the exact Node 24.20.0 close implementation and SQLite 3.53.4 Unix close contract. The native experiment is dependency evidence, not the Workboard product proof.
The final, uninstrumented product proof requires each retired WAL descriptor to disappear, the identified successor and unretired registry WAL descriptors to remain, and repeated fixed-concurrency sequences to stay bounded. It does not claim zero total descriptors or rely on garbage collection/process exit.
Test-only CI recovery
The candidate adds only the already-landed acquisition fixture from
0d830e9e74488c1ee5a3af461b147cb683f0581f(#136146) on top of the product-testedhead. This is an exact one-file port, not an import of that commit's broader
Gateway changes. Its new helper dependencies already match.
All production, dependency and package inputs remain identical, so the complete
installed Workboard proof above is retained without rebuilding or replaying it.
The fresh acquisition run passed all 29 cases, including the previously failing
GatewayClient authentication/rejected-shutdown case. Socket closure, server
ownership and selector assertions are unchanged. The fixture isolates and joins
the deliberately retained raw-close cases.
The failure in CI run 33927539775
is preserved. Its precise close-order cause is not claimed proven by this port.
Fresh exact-head CI run 33931014430
passed, including
checks-node-compact-large-1, and the fresh independent reviewpassed. The old merge input was not rerun.
Checks
git diff --checkpassed.Focused commands:
Review dispositions and scope
Both ClawSweeper rank-up moves are addressed: a semantic current-main port and actual packaged SQLite lifecycle proof. The submitted generic registry changes are omitted because current main already owns cache eviction and command draining. The old registration test-helper path is not an executable test; current loader/runtime/command controls were run instead.
The September 4 23:48 UTC review found no patch defect and judged product proof
sufficient, but could not fetch the native explanatory sources. The retained
Node source at lines 1030–1036 and 1431–1440 finalizes statements and invokes
sqlite3_close_v2; SQLite's Unix source at lines 1244–1255 and 2338–2371 explainsand implements deferred file-descriptor close while another connection holds
locks. Fresh upstream reads matched both retained complete sources. Both were
supplied directly to the fresh independent review, which passed all 11 passes
on
0b22be085f1dad5966a33349f0e582469ce1f622with no findings at LandPR's requiredP0 threshold. The review included 588 complete evidence artifacts.
This resolves the review's source-inspection request and its associated decision:
the native contract was checked, not waived or accepted unchecked. No replacement
contributor product proof or change to another registry's lifetime was needed.
Named follow-ups remain separate: generic registration rollback drops runtime cleanup callbacks, and non-activating prepared-runtime discovery eagerly opens its own store. Installed failing-plugin and acquisition-stack diagnostics are retained. This PR does not redefine another registry's lifetime or claim to repair generic rollback.
The original contribution by @NianJiuZst remains in ancestry and retains primary credit. AI-assisted.