diff --git a/src/tree_store/page_store/page_manager.rs b/src/tree_store/page_store/page_manager.rs index a794e46b..1741702a 100644 --- a/src/tree_store/page_store/page_manager.rs +++ b/src/tree_store/page_store/page_manager.rs @@ -665,21 +665,6 @@ impl TransactionalMemory { page_number: PageNumber, hint: PageHint, ) -> Result { - // We must not retrieve an immutable reference to a page which already has a mutable ref to it - #[cfg(debug_assertions)] - { - debug_assert!( - !self.open_dirty_pages.lock().unwrap().contains(&page_number), - "{page_number:?}", - ); - *(self - .read_page_ref_counts - .lock() - .unwrap() - .entry(page_number) - .or_default()) += 1; - } - let range = page_number.address_range( self.page_size as u64, self.region_size, @@ -691,6 +676,20 @@ impl TransactionalMemory { .storage .read(range.start, len, hint, CachePriority::default_btree)?; + // We must not retrieve an immutable reference to a page which already has a mutable ref to it + #[cfg(debug_assertions)] + { + let dirty_pages = self.open_dirty_pages.lock().unwrap(); + debug_assert!(!dirty_pages.contains(&page_number), "{page_number:?}"); + *(self + .read_page_ref_counts + .lock() + .unwrap() + .entry(page_number) + .or_default()) += 1; + drop(dirty_pages); + } + Ok(PageImpl { mem, page_number,