Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errant panic with debug_assertions #708

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/tree_store/page_store/page_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,21 +665,6 @@ impl TransactionalMemory {
page_number: PageNumber,
hint: PageHint,
) -> Result<PageImpl> {
// 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,
Expand All @@ -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,
Expand Down
Loading