diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 0c5279608..063f41154 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -3482,7 +3482,7 @@ impl BTreeCursor { if *new_id != page.get().id { page.get().id = *new_id; self.pager - .update_dirty_loaded_page_in_cache(*new_id, page.clone())?; + .upsert_page_in_cache(*new_id, page.clone(), true)?; } } diff --git a/core/storage/pager.rs b/core/storage/pager.rs index 88d125dfa..cbbcb9dcf 100644 --- a/core/storage/pager.rs +++ b/core/storage/pager.rs @@ -2521,16 +2521,19 @@ impl Pager { } } - pub fn update_dirty_loaded_page_in_cache( + pub fn upsert_page_in_cache( &self, id: usize, page: PageRef, + dirty_page_must_exist: bool, ) -> Result<(), LimboError> { let mut cache = self.page_cache.write(); let page_key = PageCacheKey::new(id); // FIXME: use specific page key for writer instead of max frame, this will make readers not conflict - assert!(page.is_dirty()); + if dirty_page_must_exist { + assert!(page.is_dirty()); + } cache.upsert_page(page_key, page.clone()).map_err(|e| { LimboError::InternalError(format!( "Failed to insert loaded page {id} into cache: {e:?}"