fix(sqlite-native): delete metadata before chunk range#4638
Conversation
PR Review: fix(sqlite-native): delete metadata before chunk rangeThe fix is directionally correct. Deleting metadata before chunks is the crash-safe ordering: if the process is killed between the two operations, you end up with orphaned chunks (wasted space) rather than live metadata pointing at missing chunks (potential read-time corruption). Inconsistency with the WASM VFSThe CLAUDE.md requirement says: "The native Rust VFS and the WASM TypeScript VFS must match 1:1." This PR only updates the native Rust VFS, leaving the WASM VFS out of sync. In rivetkit-typescript/packages/sqlite-vfs/src/vfs.ts (lines 1402-1407), the #delete method still deletes chunks before metadata: The WASM VFS is also internally inconsistent: xTruncate (~line 1293) carries a comment explicitly motivating metadata-first order ("Update metadata first so a crash leaves orphaned chunks rather than metadata pointing at missing chunks (corruption)") but #delete does the opposite. Suggested fix for the WASM VFS #delete methodSummary
The native fix is correct — please also update packages/sqlite-vfs/src/vfs.ts in the same change to keep both implementations in sync and fix the internal inconsistency in the WASM VFS. |
12c0baa to
61b5457
Compare
459dd12 to
d7b2c43
Compare
61b5457 to
bc7e3d7
Compare
d7b2c43 to
6c17fae
Compare
bc7e3d7 to
49fae2b
Compare
6c17fae to
a070720
Compare
49fae2b to
acf0da5
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: