Repository navigation
fix(update): prevent database lock failures after validation - #155138
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. |
Include the unchanged lifecycle repair from #155138. The published updater proof reproduced Doctor closing cached agent databases while the transcript worker claimed its lease; the native trace confirms the same owner race.
Keep incognito successor work with its memory owner, and let projection waiters revalidate cached-handle turnover within their captured lifecycle. Retain exact failed leases for canonical cleanup instead of replaying a historic error, and join that recovery before the worker pool closes. The retained cleanup error had prevented test mock reset and caused later FIFO and projection assertions to fail. Preserve all existing assertions and cover failed drainage, recovery after fault removal, and pool shutdown.
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 6:53 PM ET / 22:53 UTC. ClawSweeper reviewWhat this changesMake database cleanup wait for transcript workers and their lease releases, while preserving incognito sessions and recovering interrupted projection reads. Merge readiness✅ Ready for maintainer review Keep open: the settlement gap remains on current main and in the latest release. The patch addresses it through the existing lifecycle owner, and the reviewed delta has no blocking correctness finding. Priority: P1 Review scores
Verification
How this fits togetherTranscript reconciliation builds searchable projections from stored conversations using background workers. Doctor and update validation must settle those workers before closing agent databases. flowchart TD
A[Stored conversations] --> B[Transcript reconciliation]
B --> C[Background worker and database lease]
C --> D[Searchable projections]
E[Doctor or update cleanup] --> F[Revoke new work and await settlement]
B --> F
F --> G[Release leases and close databases]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +101, Tests +170. Total +271 across 6 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. Technical reviewBest possible solution: Keep transcript admission, lease recovery, and database closure under the existing lifecycle owner without changing stored data, timeouts, or user settings. Do we have a high-confidence way to reproduce the issue? Yes, the source exposes the unjoined worker-lease/agent-close race, and the supplied investigation records a native failure trace and failing regressions. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes. Extending the existing resource lifecycle repairs the ownership gap directly, preserves original reconciliation errors, and avoids retries, larger timeouts, or a competing cleanup owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1497878e0bc6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…w#155138) * fix(update): settle transcript workers before closing agent databases Join accepted reconciliation and native lease release before cached database close during Doctor settlement. Revoke late admission while retaining custody when cleanup fails. Related: openclaw#154381, openclaw#154114, openclaw#144858. * fix(sessions): recover reconciliation across database closure Keep incognito successor work with its memory owner, and let projection waiters revalidate cached-handle turnover within their captured lifecycle. Retain exact failed leases for canonical cleanup instead of replaying a historic error, and join that recovery before the worker pool closes. The retained cleanup error had prevented test mock reset and caused later FIFO and projection assertions to fail. Preserve all existing assertions and cover failed drainage, recovery after fault removal, and pool shutdown.
Related: #154381, #154114, #144858, #154674.
What Problem This Solves
Fixes updates failing with
database is lockedafter candidate validation passes when deferred transcript reconciliation overlaps Doctor's agent-database cleanup.User Impact
Updates wait for admitted transcript work and its database leases to settle before closing agent databases. Transcript contents remain intact, and incomplete native cleanup remains an error rather than being reported as success.
Why This Change Was Made
The transcript pool tracked its own operations, but agent maintenance did not own or await them. A delayed transcript worker could start claiming a lease while Doctor released a cached agent's lease in the same shared database. Registering the entire operation with the existing agent-resource lifecycle closes that gap: revocation prevents new work while preserving the release task needed to finish already admitted work.
This is the standalone settlement repair. It retains all Doctor lint checks and the base canary behavior. Schemas, stored data formats, options, dependencies, and busy timeouts are unchanged.
Thanks to @ZaneMc-AO and @agebreak0083 for the reports that led to this investigation.
Evidence
Lifecycle follow-up at
65a362fcd52f23f9bc200127a519f6b347161283The failing CI rows are regressions introduced by the original settlement change. Incognito disposal revoked a successor's queued projection work; cached-handle closure canceled a projection before admission and blocked its polling reader; and a retained lease-cleanup error survived fault removal, preventing test teardown from resetting mocks and causing later FIFO/projection failures.
The reconciliation owner now preserves incognito authority, revalidates an interrupted disk projection within the waiting caller's captured environment and lifecycle, and retains the exact lease release input so canonical drainage can recover. Drainage joins recovery before pool shutdown and native database closure. Persistent cleanup failure still refuses closure; the original reconciliation error is preserved.
Failed shard runs out of three, using the original CI file queue and effective hosted setting of two forks:
fe70cf7e4339950ed5640aa903deef6bafThe FIFO assertion itself fails 2/3 on both original variants. In each remaining run, the same retained cleanup errors instead poison other mocks. Main and the repaired candidate pass the assertion 3/3. All 36 queue receipts match the original CI merge's file-size order; no serial worker pin was introduced. Head's incognito shard has 84 rather than 85 files because one newer main test does not exist at that revision.
The repaired matrix passed 10,506 assertions, with zero failures or unhandled errors and 15 existing platform skips. Its longest individual test was 19.059 seconds; the longest file executed in 39.796 seconds. Maintenance FIFO fell from the reproduced 120-second timeout to 20–29 ms.
The strengthened lease test fails against the original production owners and passes after restoration of the exact candidate. It verifies refusal while the injected fault remains, recovery after removal, zero remaining leases, and concurrent pool shutdown. Both the producer lease suite and the maintenance victim pass 20/20 standalone runs; the final seven-file owner/sibling run also passes in 46.01 seconds wall. The required single-worker lease command passes eight tests in 26.83 seconds wall (Vitest: 24.65 seconds, 21% tests and 71% transform). Standalone wall medians are 21.145 seconds for the lease file and 15.525 seconds for the maintenance file; preparation dominates those wall times.
Final-source
check:changed: passed (exit 0, 1818.91 seconds wall; includes core and core-test types, lint, export scans, and repository guards). Independent P1 review of the complete PR diff: scoped-clean. PR CI will rerun on the pushed head; its test durations are pending.Interdiff versus
fe70cf7e433: production +87/−30, tests +21/−5. Complete PR: production +134/−33, tests +194/−24. The follow-up introduces no schema, options, dependency, baseline, timeout, suppression, or test-assertion weakening changes. The local rebase was proof only; this follow-up remains a direct child of the original PR head.Fixed matrix Testboxes: incognito
tbx_01m32ysmbk2hpgs1b4pmcxdaey(run); pollingtbx_01m32ysj9a78hd19khgwjn57er(run); drainagetbx_01m32ysmannxd66gtxvj7b9rqa(run). The wrapper/test results are the proof; stopping owned leases can mark the provisioning workflows canceled.Auto-merge remains off for maintainer re-review. No landing.
Original standalone update/package proof at fe70cf7
BEGIN IMMEDIATEwhile a transcript worker was claiming its independent lease. The peer transaction interval was 0.421 ms; the failed BEGIN occurred after that transaction began and before its COMMIT call. The fix joins that lifecycle rather than adding retries.node scripts/run-vitest.mjs src/test-utils/openclaw-test-state.test.ts src/config/sessions/session-transcript-reconcile-pool.test.ts src/config/sessions/session-transcript-reconcile.lifecycle.test.ts: 51 tests / three files passed, two shards, 35.98s wrapper wall. Shards: 17.34s wall (6% tests) and 16.73s wall (47% tests).e62832eb31df99cbc684c99dbf31c8f4e0f681ea, containing these exact five files on the same pinned main, passed the full changed gate including production/test types. This standalone run adds its own package build and original-order owner tests; no separate standalone typecheck invocation is claimed.fe70cf7e4335d7f3caea07e8c8ca1eeb385a8049.The tests assert worker-lease release before native closure, zero remaining agent leases, preserved transcript bytes, recovery release after native worker exit, and refusal of delayed first admission. An older assertion expecting immediate maintenance refusal while a worker was deliberately paused was removed because maintenance now waits for that worker's lifecycle to settle; synchronous-close lease protection remains covered.
The original standalone source was pinned main
db113b13a3bb8d59409b3c4ecb9d5d1e06c3343aplus exactly these five files. The proof verifies their hashes, 19 unchanged-main invariants, full original Doctor lint, main canary behavior, schema 22, and absence of the generation-sharing modules. The standalone branch merges cleanly with subsequently advanced main8c56f7239e98dbee1369e036d6b594fd560b9d9d.The realistic synthetic fixture restores ten agents/ten v19 DBs (365.8 MiB total, 338.7 MiB largest) and seven genuine npm 2026.9.5 plugins before each hop: Codex, WhatsApp, Discord, Slack, Deepseek, Mistral and Venice (477.5 MiB total). Every hop freshly installs the published 2026.9.4 updater and runs
openclaw update --tag <candidate.tgz> --yes --json --no-restart --timeout 1800. Its 300-second combined validation clamp is unchanged. Isolated state and free canary ports are used; no inference, operator Gateway or managed-service restart is claimed.All final DBs reach schema 22 through the v19→v21 path, with correct ownership,
integrity_check=ok, zero foreign-key violations, and unchanged raw transcript/trajectory hashes. Advisory plugin migration-pending warnings retain their source inputs and do not fail the update.Seconds, min / median / max across three uninstrumented hops. The validating ledger begins before staging, so it is a conservative upper bound on the combined-validator interval. These are standalone outcome measurements on a separate lease, not a causal performance comparison with the historical failing runs.
pnpm build:packagepassed in 7m07.1s, chiefly declaration generation; packaging passed. Candidate tarball SHA-256:cc48e82d0fd7d2d8ce5ff4e18f5d97e22c1112a8d31e7e71cf6d11113600d699.Testbox lease
tbx_01m32qq832r4e0xbr4qtqvqmen(run): native proof batch exit 0, all post-build/test/hop source checks passed. The owned lease was stopped after evidence collection. The original broader changed gate ran ontbx_01m32k1pzgzmz2rtwbm4jkhdeb(run). No slow or flaky test was encountered in the standalone replay; no retries, larger timeouts, weaker assertions, skips or baseline changes were introduced.