Repository navigation
perf(sqlite): stop no-op startup repair from blocking Gateway writes - #115193
Conversation
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 10:38 AM ET / 14:38 UTC. ClawSweeper reviewWhat this changesThis PR makes automatic shared-SQLite migration read the schema first and skip exclusive repair when the database is already current, reducing CLI startup contention with Gateway writes. Merge readinessThe PR remains necessary: current Priority: P2 Review scores
Verification
How this fits togetherOpenClaw stores shared runtime state in a SQLite database used by both CLI processes and the Gateway. Automatic startup migration currently invokes schema repair before normal work; this change decides whether repair is needed without first taking the writer path. flowchart LR
A[CLI or automation startup] --> B[Automatic state migration]
B --> C[Read-only schema gate]
C -->|Canonical and current| D[Continue without repair]
C -->|Legacy damaged or uncertain| E[Exclusive schema repair]
D --> F[Gateway and state writes]
E --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource +39, Tests +46. Total +85 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Land the focused read-only gate after a maintainer confirms that the current-main state-schema invariants remain complete and the branch is refreshed against current Do we have a high-confidence way to reproduce the issue? Yes, at source level: the added regression holds a SQLite writer transaction open and verifies that automatic migration of a current schema completes without waiting for that writer. The supplied Testbox result reports the focused tests passing, but this read-only review did not rerun them. Is this the best way to solve the issue? Yes. A narrow read-only canonical-schema gate preserves the existing exhaustive repair fallback for migration, malformed, unreadable, and noncanonical databases while removing avoidable contention on the known-current path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3fa4805563eb. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: test(codex): de-flake attempt turn-watch timing tests (#115258) fix: preserve retryable ACPX lease ownership (#115247) fix: serialize ACPX lease ownership transitions fix: retain ACPX leases across wrapper reconnects refactor: parse ACPX lease command identity fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752) refactor(config): retire compaction truncateAfterCompaction gate (#115206) improve(ui): reduce duplicate chat startup work (#114743) fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221) perf(pr): cache complete small file lists (#115199) perf(sqlite): skip no-op automatic schema repair (#115193) docs(browser): correct Docker sandbox setup (#115254) fix(ui): avoid duplicate session refreshes during startup (#114764) # Conflicts: # ui/src/pages/agents/panels-tools-skills.browser.test.ts
* origin/main: test(codex): de-flake attempt turn-watch timing tests (#115258) fix: preserve retryable ACPX lease ownership (#115247) fix: serialize ACPX lease ownership transitions fix: retain ACPX leases across wrapper reconnects refactor: parse ACPX lease command identity fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752) refactor(config): retire compaction truncateAfterCompaction gate (#115206) improve(ui): reduce duplicate chat startup work (#114743) fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221) perf(pr): cache complete small file lists (#115199) perf(sqlite): skip no-op automatic schema repair (#115193) docs(browser): correct Docker sandbox setup (#115254) fix(ui): avoid duplicate session refreshes during startup (#114764)
What Problem This Solves
Fixes an issue where routine CLI startup could hold the shared SQLite writer lock for roughly two seconds even when the database schema was already current. Repeated status and automation commands could then make Gateway writes wait behind no-op schema repair and turn lightweight CLI reads into multi-second operations.
Why This Change Was Made
Automatic legacy migration now performs a read-only canonical-schema gate first and enters the existing exclusive repair path only when a migration, schema mismatch, unreadable database, or other uncertainty is detected. Explicit Doctor repair remains exhaustive, including integrity checks and index repair.
User Impact
Routine CLI commands no longer run a full shared-state integrity/repair transaction on every new process. This reduces startup latency and avoids unnecessary contention with a running Gateway while preserving fail-closed repair behavior for old, damaged, or noncanonical databases.
Evidence
schema_meta.updated_at.pnpm test src/state/openclaw-state-db.test.ts src/infra/state-migrations.test.ts— 164 passed on Blacksmith Testboxtbx_01kymapw8km35a2c99t050tnyb.pnpm check:changed— passed core production/test typechecks, targeted lint, formatting, schema guards, import-cycle checks, and repository guards on the same Testbox.gpt-5.6-sol, high) — clean; no accepted/actionable findings.