mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 12:34:22 +01:00
Closes #2363 ## What The following sequence of actions is possible: ``` Some committed frames already exist in the WAL. shared.pages_in_frames.len() > 0. Brand new connection does this: BEGIN ^-- deferred, no read tx started yet, so its `self.start_pages_in_frames` is `0` because it's a brand new WalFile instance ROLLBACK <-- calls `wal.rollback()` and truncates `shared.pages_in_frames` to length `0` PRAGMA wal_checkpoint(); ^-- because `pages_in_frames` is empty, it doesnt actually checkpoint anything but still sets shared.max_frame to 0, causing effectively data loss ``` ## Fix - Only call `wal.rollback()` for write transactions - Set `start_pages_in_frames` correctly so that this doesn't happen even if a regression starts calling `wal.rollback()` again Reviewed-by: Preston Thorpe (@PThorpe92) Closes #2366