From 44152f11d030de35e83167fd13715256a04d7a1b Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Tue, 7 Oct 2025 11:15:48 +0200 Subject: [PATCH] core/mvcc/logical-log: switch RwLock to parking_lot --- core/mvcc/database/mod.rs | 2 +- core/mvcc/persistent_storage/mod.rs | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/core/mvcc/database/mod.rs b/core/mvcc/database/mod.rs index 675695b78..f88d21251 100644 --- a/core/mvcc/database/mod.rs +++ b/core/mvcc/database/mod.rs @@ -2016,7 +2016,7 @@ impl MvStore { } StreamingResult::Eof => { // Set offset to the end so that next writes go to the end of the file - self.storage.logical_log.write().unwrap().offset = reader.offset as u64; + self.storage.logical_log.write().offset = reader.offset as u64; break; } } diff --git a/core/mvcc/persistent_storage/mod.rs b/core/mvcc/persistent_storage/mod.rs index ede456bc3..0c5514f6c 100644 --- a/core/mvcc/persistent_storage/mod.rs +++ b/core/mvcc/persistent_storage/mod.rs @@ -1,5 +1,6 @@ +use parking_lot::RwLock; use std::fmt::Debug; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; pub mod logical_log; use crate::mvcc::database::LogRecord; @@ -20,7 +21,7 @@ impl Storage { impl Storage { pub fn log_tx(&self, m: &LogRecord) -> Result { - self.logical_log.write().unwrap().log_tx(m) + self.logical_log.write().log_tx(m) } pub fn read_tx_log(&self) -> Result> { @@ -28,30 +29,27 @@ impl Storage { } pub fn sync(&self) -> Result { - self.logical_log.write().unwrap().sync() + self.logical_log.write().sync() } pub fn truncate(&self) -> Result { - self.logical_log.write().unwrap().truncate() + self.logical_log.write().truncate() } pub fn get_logical_log_file(&self) -> Arc { - self.logical_log.write().unwrap().file.clone() + self.logical_log.write().file.clone() } pub fn should_checkpoint(&self) -> bool { - self.logical_log.read().unwrap().should_checkpoint() + self.logical_log.read().should_checkpoint() } pub fn set_checkpoint_threshold(&self, threshold: u64) { - self.logical_log - .write() - .unwrap() - .set_checkpoint_threshold(threshold) + self.logical_log.write().set_checkpoint_threshold(threshold) } pub fn checkpoint_threshold(&self) -> u64 { - self.logical_log.read().unwrap().checkpoint_threshold() + self.logical_log.read().checkpoint_threshold() } }