Repository navigation
fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification - #205668
Conversation
…not fail verification On Windows, SQLite's byte-range locks at 1 GiB are mandatory. While the update migration owner retains EXCLUSIVE on a database larger than 1 GiB, the post-migration generation read failed with EBUSY. SQLite stores no content in those 512 bytes, so the main-database digest now hashes them as the zeros SQLite leaves, matching a full read. Refs #197083 Co-authored-by: RomneyDa <[email protected]>
…not fail verification Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 2a84fae0-c618-43f3-881b-f5bc9ca55842
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR hashes SQLite’s 512 lock bytes as zeros when computing main-database generations, while continuing to hash WAL and journal files completely. Example: A Windows process reads a 1.15 GB SQLite database while another SQLite connection retains EXCLUSIVE locking.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this PR: it addresses a concrete Windows update failure still present on main, and review found no actionable code defect. Reviewed head: Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor retains native SQLite exclusion during migration, then asks an isolated worker to verify database generations used for publication and recovery attribution. flowchart TD
A[Installed Doctor] --> B[Migration owner]
B --> C[Retained SQLite exclusion]
B --> D[Generation worker]
D --> E[Database and sidecar hashes]
E --> F[Publication receipt]
Technical reviewBest possible solution: Retain the focused database-hashing repair within the existing generation and snapshot-verification owners. Do we have a high-confidence way to reproduce the issue? Current source exposes the full-file read under retained native exclusion, and the PR reports a matching Windows base/fix reproduction; this review executed no target code. Is this the best way to solve the issue? Normalizing only SQLite’s unused lock range addresses the failing read without releasing migration exclusion, swallowing EBUSY, or weakening WAL and journal verification. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2cb81bbb38a1. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +50, Tests +17. Total +67 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 25, 2026, 8:24 PM ET / November 26, 2026, 01:24 UTC. |
…not fail verification (#205668) * fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification On Windows, SQLite's byte-range locks at 1 GiB are mandatory. While the update migration owner retains EXCLUSIVE on a database larger than 1 GiB, the post-migration generation read failed with EBUSY. SQLite stores no content in those 512 bytes, so the main-database digest now hashes them as the zeros SQLite leaves, matching a full read. Refs #197083 Co-authored-by: RomneyDa <[email protected]> * fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 2a84fae0-c618-43f3-881b-f5bc9ca55842 --------- Co-authored-by: RomneyDa <[email protected]> Release adaptation for 2026.11.11: added only the lock-bytes regression in update-database-generations.test.ts; the neighboring retained-WAL test belongs to a change not on 2026.11.11. (cherry picked from commit 69b81b5) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
…irement-rule * origin/main: (172 commits) test(gateway): expect a revoked person's Goal retry to be hidden as not found (#205698) fix: keep browser disabled when only hardening relay authentication (#203137) fix: recover Linux stream automations after command-anchor crashes (#203149) fix(whatsapp): identify voice-note captions as text in delivery receipts (#205381) fix(test): unblock restart-auth plugin and worker publication qualification (#205679) chore(ui): refresh control ui locales (#205691) fix: reduce memory during SQLite usage refresh (#201064) fix(plugins): readmit native captures with a dangling host link chore(i18n): refresh native locales (#205680) fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification (#205668) fix(skill-workshop): skip the skill diet for skills with Markdown outside support directories (#204881) fix(plugins): clarify dated SDK migration notices (#200932) fix: keep the resident launcher when reinstalling Gateway (#205655) fix: show the whole reply when you reopen a TUI session (#200455) test(ui): wait for restored speech player authorization (#199502) feat: let agents post approved GitHub comments (#204301) fix(agents): honor imageMaxDimensionPx at the provider and CLI image handoffs (#205663) chore(ui): refresh control ui locales (#205664) fix(google): preserve playback when Google Live splits audio into parts (#205364) fix: show named characters in exported session messages (#205362) ...
…not fail verification (openclaw#205668) * fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification On Windows, SQLite's byte-range locks at 1 GiB are mandatory. While the update migration owner retains EXCLUSIVE on a database larger than 1 GiB, the post-migration generation read failed with EBUSY. SQLite stores no content in those 512 bytes, so the main-database digest now hashes them as the zeros SQLite leaves, matching a full read. Refs openclaw#197083 Co-authored-by: RomneyDa <[email protected]> * fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 2a84fae0-c618-43f3-881b-f5bc9ca55842 --------- Co-authored-by: RomneyDa <[email protected]>
…not fail verification (#205668) * fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification On Windows, SQLite's byte-range locks at 1 GiB are mandatory. While the update migration owner retains EXCLUSIVE on a database larger than 1 GiB, the post-migration generation read failed with EBUSY. SQLite stores no content in those 512 bytes, so the main-database digest now hashes them as the zeros SQLite leaves, matching a full read. Refs #197083 Co-authored-by: RomneyDa <[email protected]> * fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 2a84fae0-c618-43f3-881b-f5bc9ca55842 --------- Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 69b81b5) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Problem
Windows updates whose agent or state database is larger than 1 GiB fail post-install Doctor with:
This is the recurring Windows variant in #197083 (2026.11.6 → 11.7 → 11.8 → 11.9 → 11.10). The reporter's main agent database is about 5 GB.
Root cause:
updateSqliteMigrationSteps(update-doctor-migration-attribution.ts) keepsPRAGMA locking_mode=EXCLUSIVEon the source while it reads the post-migration generation. SQLite's lock bytes sit at offset 1 GiB: the pending byte, the reserved byte and the 510-byte shared range. On POSIX those locks are advisory. On Windows,LockFileExlocks are mandatory, so any other handle that reads[0x40000000, 0x40000200)getsERROR_LOCK_VIOLATION. Node reports that asEBUSY ... read, and the main-database hash infingerprintFile(sqlite-file-generation.ts) fails there. Databases under 1 GiB have no lock-byte page, which is why this only hits large installs.Small
-shmreads are not the cause: Windows SQLite locks-shmat offset 120 and above, and the WAL-index header read covers only bytes 0–95. The earlier forced-lock experiment had to inject a lock there by hand.Fix
SQLite never stores content in the lock-byte page. The main-database digest now hashes those 512 bytes as zeros instead of reading them. SQLite never writes that page, and backups and VACUUM skip it, so it always reads back as zeros. The digest therefore matches a full read, and existing captures and receipts stay valid. The WAL and journal are still hashed in full because they have no lock bytes and a WAL can hold real frame data at that offset.
Accepted edge case: if another tool wrote nonzero bytes into the lock page, they now hash as zeros. That page is not database content, so this does not hide a database change.
Evidence
hashes SQLite's lock bytes as the zeros SQLite leaves. On base it fails with a different digest; with the fix it passes.readUpdateDatabaseGenerationwas bundled from base and from this branch. A second process held the same native exclusion the migration owner takes (PRAGMA schema_version, thenlocking_mode=EXCLUSIVE; BEGIN EXCLUSIVE; ROLLBACK):EBUSY: resource busy or locked, read(matches the field reports)11003e4d…), so digests are compatibleb33cfc60…). That is exactly the unlocked read's empty-reader alternate, and the content digest is identical (e96fafa8…), so the existing admission accepts it.node scripts/run-vitest.mjsonupdate-database-generations,update-doctor-migration-wal-rebuild,update-database-backup-engineandsqlite-snapshottests: 139 passed, 2 skipped.pnpm tsgo:core, oxlint, format check andgit diff --checkall pass.Not covered: a full managed Windows
openclaw updatewith a database larger than 1 GiB. The proof above runs the production generation reader under the production lock sequence, not the whole updater. Private-copy paths (copySourceFile) still read the whole file, but the failing post-migration read uses the drained, copy-free path aftertruncateSqliteWal.Refs #197083
Worked on by