pager: allow upserted cached page not to be dirty

This commit is contained in:
Jussi Saurio
2025-10-21 11:29:52 +03:00
parent 5b01605fae
commit 86d5ad6815
2 changed files with 6 additions and 3 deletions

View File

@@ -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)?;
}
}

View File

@@ -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:?}"