Repository navigation
fix: serialize periodic database maintenance with session writes - #148941
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 16, 2026, 4:11 AM ET / 08:11 UTC (Revision 10). ClawSweeper reviewWhat this changesQueues periodic SQLite maintenance behind session writes and retains Worker ownership until failed native transactions safely settle. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: current main still runs periodic maintenance outside the writer queue. No introduced correctness or security defect was found, and the previous review has no outstanding findings. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw stores session data in per-agent SQLite databases. Session writes and periodic checkpoint/vacuum work share those databases, so maintenance must respect writer ownership and connection lifetime. flowchart TD
A[Periodic maintenance timer] --> B[Coalesce pending maintenance]
C[Session writes] --> D[Existing database writer queue]
B --> D
D --> E[Check current connection and authority]
E --> F[Checkpoint and bounded vacuum]
F --> G[Transaction settlement or native Worker exit]
G --> D
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +138, Tests +824. Total +962 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep periodic maintenance under the existing writer owner, preserving connection validity checks, bounded vacuum work, and native settlement before admission release. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main's periodic timer bypasses the session writer queue, and the added regressions exercise that contention boundary. No runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? Yes. Reusing the existing writer queue and poisoned-transaction cleanup contract is a focused repair that preserves stored data and public behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b47ba1021fff. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
Preserve the reviewed component delta while including the canonical CI fixture and shard ownership repairs.
Require native exit before initialization failure rejection and retain queued admission custody without granting an exited Worker. Related: #130741
Propagate the existing poisoned-transaction error after deferred maintenance so reclamation retains its writer until native exit. Cover real periodic vacuum failures and successful rollback or close cleanup through the retained worker.
Preserve queued WAL maintenance and the native-settlement guard while incorporating current archive reads, maintenance preparation, and reader cleanup.
178bd14 to
d2c44d3
Compare
|
Merged via squash.
|
…nclaw#148941) * fix(sqlite): admit periodic agent maintenance through its writer * test(sqlite): await queued vacuum after reclamation settlement * test(sessions): cover Worker failure and admission settlement Require native exit before initialization failure rejection and retain queued admission custody without granting an exited Worker. Related: openclaw#130741 * fix(sqlite): retain worker admission after failed maintenance Propagate the existing poisoned-transaction error after deferred maintenance so reclamation retains its writer until native exit. Cover real periodic vacuum failures and successful rollback or close cleanup through the retained worker.
Related: #130741
What Problem This Solves
Periodic SQLite maintenance could race a reserved session write. Failed deferred maintenance could also release admission while its native Worker still held a transaction lock.
User Impact
Checkpoint and incremental-vacuum work waits for the existing database writer owner. Retired connections do not receive delayed maintenance, and session writes retain FIFO ordering. A poisoned transaction keeps the writer reserved until the Worker actually exits.
Why This Change Was Made
Periodic maintenance coalesces behind the existing admission queue and rechecks the timer and exact connection after waiting. Retained Workers flush pending maintenance under current parent authority before and after their operation. The existing poisoned-transaction check reaches the cleanup owner if commit, rollback, and close all fail, so that owner cannot report settlement early. Checkpoint behavior and the 512-page vacuum bound remain unchanged.
Evidence
Exact-head CI passed on
d2c44d378514bdcf47799e7b22f9f9a317544179: 125 jobs succeeded and 15 were skipped. The tested merge was4108afdb8a83f3ec722d43005ff8a0de1142612a. Eight selected owner files account for 330 passing cases with no skipped or failed cases, including all six native pre/post-maintenance failure and cleanup cases, Doctor revalidation, prepared reads, transcript/provenance, read-only companions, and shared-state open behavior.Earlier focused proof passed 79 tests and canonical changed checks on its recorded integration. The original post-maintenance regression reproduced premature settlement while an independent connection remained locked; the repaired case verifies writer exclusion, retained ownership, actual exit, and subsequent write recovery. The reviewed feature patch is unchanged.
Current-main composition preserves normalized admission-service registrations, canonical validation, cold-open preparation, reader cleanup, and native error ownership. Any preparation that changes the published head requires matching CI before merge. These results do not establish the overall 500 ms Swarm performance target.