From b8f4baf7540e063c6b2cb97b8fb06e67322bec52 Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 7 Oct 2023 20:09:11 -0700 Subject: [PATCH] Reduce lock duration in non_durable_commit() --- src/tree_store/page_store/page_manager.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tree_store/page_store/page_manager.rs b/src/tree_store/page_store/page_manager.rs index 9f218712..721c8253 100644 --- a/src/tree_store/page_store/page_manager.rs +++ b/src/tree_store/page_store/page_manager.rs @@ -582,6 +582,9 @@ impl TransactionalMemory { debug_assert!(self.open_dirty_pages.lock().unwrap().is_empty()); assert!(!self.needs_recovery.load(Ordering::Acquire)); + self.allocated_since_commit.lock().unwrap().clear(); + self.storage.write_barrier()?; + let mut state = self.state.lock().unwrap(); let secondary = state.header.secondary_slot_mut(); secondary.transaction_id = transaction_id; @@ -589,8 +592,6 @@ impl TransactionalMemory { secondary.system_root = system_root; secondary.freed_root = freed_root; - self.allocated_since_commit.lock().unwrap().clear(); - self.storage.write_barrier()?; // TODO: maybe we can remove this flag and just update the in-memory DatabaseHeader state? self.read_from_secondary.store(true, Ordering::Release);