diff --git a/core/lib.rs b/core/lib.rs index dc9dea9a7..779fe843a 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -1141,6 +1141,8 @@ impl Connection { Ok(()) } + /// Try to read page with given ID with fixed WAL watermark position + /// This method return false if page is not found (so, this is probably new page created after watermark position which wasn't checkpointed to the DB file yet) #[cfg(all(feature = "fs", feature = "conn_raw_api"))] pub fn try_wal_watermark_read_page( &self, @@ -1161,6 +1163,8 @@ impl Connection { Ok(true) } + /// Return unique set of page numbers changes after WAL watermark position in the current WAL session + /// (so, if concurrent connection wrote something to the WAL - this method will not see this change) #[cfg(all(feature = "fs", feature = "conn_raw_api"))] pub fn wal_changed_pages_after(&self, frame_watermark: u64) -> Result> { self.pager.borrow().wal_changed_pages_after(frame_watermark) diff --git a/core/storage/pager.rs b/core/storage/pager.rs index 7fb5dca0a..d03c705ac 100644 --- a/core/storage/pager.rs +++ b/core/storage/pager.rs @@ -929,7 +929,7 @@ impl Pager { Ok(()) } - /// Reads a page from disk bypassing page-cache + /// Reads a page from disk (either WAL or DB file) bypassing page-cache #[tracing::instrument(skip_all, level = Level::DEBUG)] pub fn read_page_no_cache( &self, diff --git a/core/storage/wal.rs b/core/storage/wal.rs index e188e241f..475d93562 100644 --- a/core/storage/wal.rs +++ b/core/storage/wal.rs @@ -860,6 +860,11 @@ impl Wal for WalFile { "unexpected use of frame_watermark optional argument" ); + turso_assert!( + frame_watermark.unwrap_or(0) <= self.max_frame, + "frame_watermark must be <= than current WAL max_frame value" + ); + // if we are holding read_lock 0, skip and read right from db file. if self.max_frame_read_lock_index.get() == 0 { return Ok(None); diff --git a/tests/integration/functions/test_wal_api.rs b/tests/integration/functions/test_wal_api.rs index 24118dab9..2d795ea18 100644 --- a/tests/integration/functions/test_wal_api.rs +++ b/tests/integration/functions/test_wal_api.rs @@ -393,7 +393,7 @@ fn revert_to(conn: &Arc, frame_watermark: u64) -> turso_ if !has_page { continue; } - frames.push((page_id, frame.clone())); + frames.push((page_id, frame)); } let mut frame_no = conn.wal_frame_count().unwrap();