Repository navigation
refactor: retain shared database handles until their last worker closes - #147246
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. Reviewed September 13, 2026, 2:24 PM ET / 18:24 UTC (Revision 2). ClawSweeper reviewWhat this changesShared-state workers retain individual references to their SQLite connection, allowing the cache to retire it after the final worker releases it and retry failed cleanup. Merge readiness✅ Ready for maintainer review The change remains useful: current main still closes shared handles by path when a worker closes. No blocking defect was established in the pinned patch, and this maintainer-authored PR is protected from automatic closure. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s shared-state worker executes task, flow, and preference operations against a cached SQLite connection. The database cache coordinates connection ownership, worker drainage, and final cleanup. flowchart TD
A[Task and preference operations] --> B[Shared-state workers]
B --> C[Retained database references]
C --> D[Canonical database cache]
B --> E[Worker closes]
E --> F{Last reference released?}
F -->|No| D
F -->|Yes| G[Coordinated cleanup and retry]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +164, Tests +95. Total +259 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep native connection retirement in the canonical cache, with workers releasing only their own references and failed disposal remaining retryable. Do we have a high-confidence way to reproduce the issue? Not applicable as a reported production incident; the shared-worker close/reopen scenario is concrete in the regression test, but this read-only review did not execute it. Is this the best way to solve the issue? Yes. Extending the existing cache’s lifetime ownership is a focused approach, and the worker and retry paths preserve one canonical native owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c72435e19089. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit 'cf45ff4d6a9c13164463db860285a02c1c4f2e8c': test(macos): observe readiness cancellation and deadline ownership (#145056) fix(ci): route QA Profile Evidence to its run-status owner test (#147293) fix(install): preserve runtime links when Node validation fails (#147221) test(auto-reply): reuse memory session fixtures (#147262) fix: hide subagent sessions from Activity (#147253) ci: record resources for slow runtime test commands (#147254) fix(update): recognize FreeBSD boot identities in triage leases (#147243) refactor(active-memory): share closing tag line scan (#147031) fix: resume Settings autosave after Reload Config (#147136) fix(cli): keep conversation context after cancellation (#147139) fix(channels): make system-agent approval cards actionable (#147152) refactor: retain shared database handles until their last worker closes (#147246) refactor(slack): share workspace-qualified target resolution (#147024) refactor(msteams): remove duplicate quoted-table test (#147270)
* commit 'ac59d5e09eb468dc23cf95e447608b57e71b52af': (176 commits) improve(gateway): avoid redundant startup preflight work (#147285) test(macos): observe readiness cancellation and deadline ownership (#145056) fix(ci): route QA Profile Evidence to its run-status owner test (#147293) fix(install): preserve runtime links when Node validation fails (#147221) test(auto-reply): reuse memory session fixtures (#147262) fix: hide subagent sessions from Activity (#147253) ci: record resources for slow runtime test commands (#147254) fix(update): recognize FreeBSD boot identities in triage leases (#147243) refactor(active-memory): share closing tag line scan (#147031) fix: resume Settings autosave after Reload Config (#147136) fix(cli): keep conversation context after cancellation (#147139) fix(channels): make system-agent approval cards actionable (#147152) refactor: retain shared database handles until their last worker closes (#147246) refactor(slack): share workspace-qualified target resolution (#147024) refactor(msteams): remove duplicate quoted-table test (#147270) fix(qa): bind coverage IDs to producer assertions (#144000) fix(linux): explain FreeBSD desktop setup prerequisites (#147211) fix(memory): split embedding batches rejected for an input array item cap (#139541) test: isolate timing metadata persistence from inherited settings (#147112) refactor(status): retire test-only helper publication (#147071) ...
…es (openclaw#147246) * refactor: retain shared database handles until their last worker closes * refactor: remove unused shared database borrow reexport
…#146547) Related: #144592 Related: #147375 Related: #147246 Dependency: #151816 ## What Problem This Solves Stored transcript detail and note lookups return promises but still execute SQLite on the Gateway event loop. ## User Impact Transcript identity, descriptor, note, summary, and utterance lookups execute in the shared SQLite worker. Existing selectors, content, ordering, limits, and error responses are preserved. No schema migration or configuration change is required. Chronological list queries and streaming/export snapshots retain their current owners. Capture appends are a separate stacked change in #151760. ## Why This Change Was Made Eleven typed commands call the existing read kernels through the canonical shared-state worker. Compound enumeration, matching, and library reads keep one deferred snapshot. First-use schema creation finishes before those reads, canonical close drains accepted work, and existing-only task inspection stays non-creating. Meeting fixtures stop producers before asynchronous database cleanup, and canonical test routing keeps worker consumers in their owning processes. The composition preserves Doctor's device-token dispatch alongside all eleven transcript commands, shared transaction-settlement checks, plugin-reload ownership, and current test-routing changes. Chronological reads preserve their parent-timezone date function; exports preserve their snapshot lifetime. Qualified dependency history from #151816 is incorporated through normal merge ancestry. It pins the deprecated message facade at its published exports, aligns three global surface limits with the resulting smaller counts, and carries the canonical catalog-materialization prerequisite with its strict 18-read assertion. The per-entry SDK compatibility limit remains unchanged. This does not claim that dependency PR #151816 has merged. ## Evidence The current catalog carry passed a fresh normal production build in 319.083 seconds and all five real transcript/Doctor SQLite worker controls in 21.595 seconds. Fresh independent P2 review found no actionable issues. These checks cover the changed Gateway and shared-worker import closures. All 58 non-doc meeting feature files, including the combined Doctor/transcript dispatcher, remain byte-identical to `6b3c5acb8634`; storage docs only gain the qualified upstream task paragraph. The SDK owner's strict catalog control and 25 archived-list/backfill controls are reused for matching owner inputs. The strict assertion retains three binding-authority checks and zero plugin-state worker operations while accounting for 18 SQLite reads after canonical materialization changes. The shared worker composition is separately covered by the five fresh controls above. Retained compiled child CLI/Gateway proof belongs to the earlier captured-main `6c6dc44250d` composition: the test body passed in 21.539 seconds under its unchanged 180-second bound, with 404.282 seconds for the supported wrapper and private-QA build. It checks canonical SQLite state, delegated missing-session cleanup while the isolated Gateway stays alive, transcript list/show/path commands, and exported bytes. This compiled scenario was not rerun on the latest catalog carry. The preceding combined 62-file gate passed in 966.651 seconds, including production/test types, SDK/storage boundaries, formatting, lint, and three unused-export scans with zero findings. Six SDK facade tests and independent P2 review passed. The subsequent exact three SDK ratchet decreases passed all ten existing reporter tests, the canonical surface check, the changed-script gate, and fresh P2 review. Earlier reload and routing controls remain attributed to their qualified inputs. CI at `6b3c5acb8634` completed with 140 successful jobs, 14 skipped, and one substantive failure plus its aggregate gate: the shared catalog benchmark expected 20 reads but the CI main composition performed 18. That matched the SDK owner's independently reproduced prerequisite issue. This carry includes its qualified canonical prerequisite and strict assertion correction; strict equality, authority-count, and zero-I/O checks remain intact, with unchanged deadlines. The new head requires its own hosted CI before landing.
…openclaw#146547) Related: openclaw#144592 Related: openclaw#147375 Related: openclaw#147246 Dependency: openclaw#151816 ## What Problem This Solves Stored transcript detail and note lookups return promises but still execute SQLite on the Gateway event loop. ## User Impact Transcript identity, descriptor, note, summary, and utterance lookups execute in the shared SQLite worker. Existing selectors, content, ordering, limits, and error responses are preserved. No schema migration or configuration change is required. Chronological list queries and streaming/export snapshots retain their current owners. Capture appends are a separate stacked change in openclaw#151760. ## Why This Change Was Made Eleven typed commands call the existing read kernels through the canonical shared-state worker. Compound enumeration, matching, and library reads keep one deferred snapshot. First-use schema creation finishes before those reads, canonical close drains accepted work, and existing-only task inspection stays non-creating. Meeting fixtures stop producers before asynchronous database cleanup, and canonical test routing keeps worker consumers in their owning processes. The composition preserves Doctor's device-token dispatch alongside all eleven transcript commands, shared transaction-settlement checks, plugin-reload ownership, and current test-routing changes. Chronological reads preserve their parent-timezone date function; exports preserve their snapshot lifetime. Qualified dependency history from openclaw#151816 is incorporated through normal merge ancestry. It pins the deprecated message facade at its published exports, aligns three global surface limits with the resulting smaller counts, and carries the canonical catalog-materialization prerequisite with its strict 18-read assertion. The per-entry SDK compatibility limit remains unchanged. This does not claim that dependency PR openclaw#151816 has merged. ## Evidence The current catalog carry passed a fresh normal production build in 319.083 seconds and all five real transcript/Doctor SQLite worker controls in 21.595 seconds. Fresh independent P2 review found no actionable issues. These checks cover the changed Gateway and shared-worker import closures. All 58 non-doc meeting feature files, including the combined Doctor/transcript dispatcher, remain byte-identical to `6b3c5acb8634`; storage docs only gain the qualified upstream task paragraph. The SDK owner's strict catalog control and 25 archived-list/backfill controls are reused for matching owner inputs. The strict assertion retains three binding-authority checks and zero plugin-state worker operations while accounting for 18 SQLite reads after canonical materialization changes. The shared worker composition is separately covered by the five fresh controls above. Retained compiled child CLI/Gateway proof belongs to the earlier captured-main `a16c8616eac` composition: the test body passed in 21.539 seconds under its unchanged 180-second bound, with 404.282 seconds for the supported wrapper and private-QA build. It checks canonical SQLite state, delegated missing-session cleanup while the isolated Gateway stays alive, transcript list/show/path commands, and exported bytes. This compiled scenario was not rerun on the latest catalog carry. The preceding combined 62-file gate passed in 966.651 seconds, including production/test types, SDK/storage boundaries, formatting, lint, and three unused-export scans with zero findings. Six SDK facade tests and independent P2 review passed. The subsequent exact three SDK ratchet decreases passed all ten existing reporter tests, the canonical surface check, the changed-script gate, and fresh P2 review. Earlier reload and routing controls remain attributed to their qualified inputs. CI at `6b3c5acb8634` completed with 140 successful jobs, 14 skipped, and one substantive failure plus its aggregate gate: the shared catalog benchmark expected 20 reads but the CI main composition performed 18. That matched the SDK owner's independently reproduced prerequisite issue. This carry includes its qualified canonical prerequisite and strict assertion correction; strict equality, authority-count, and zero-I/O checks remain intact, with unchanged deadlines. The new head requires its own hosted CI before landing.
What Problem This Solves
Shared-state workers need to release their own reference without closing a native database handle another worker still uses.
User Impact
This is internal database lifecycle cleanup that prepares existing shared-state workers for further SQLite worker migration. It requires no configuration or data migration.
Why This Change Was Made
The existing shared-state cache now owns native-handle references. Workers retain the exact published handle, release their own reference on close, and leave final disposal to the cache. Failed final cleanup remains retryable through either the cache or the original worker, and an old released reference cannot close a replacement handle. The current read-only status-summary path keeps its existing lazy behavior.
Evidence
A full local build was not run. This does not claim Bun physical-release proof; the broker’s existing VM-exit requirement remains in force.