mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 01:04:22 +01:00
Dont fsync the WAL on read queries
This commit is contained in:
@@ -63,7 +63,7 @@ pub use storage::wal::CheckpointStatus;
|
||||
pub use storage::wal::Wal;
|
||||
pub static DATABASE_VERSION: OnceLock<String> = OnceLock::new();
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
enum TransactionState {
|
||||
Write,
|
||||
Read,
|
||||
|
||||
@@ -215,6 +215,11 @@ impl Pager {
|
||||
Ok(CheckpointStatus::Done)
|
||||
}
|
||||
|
||||
pub fn end_read_tx(&self) -> Result<()> {
|
||||
self.wal.borrow().end_read_tx()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Reads a page from the database.
|
||||
pub fn read_page(&self, page_idx: usize) -> Result<PageRef> {
|
||||
trace!("read_page(page_idx = {})", page_idx);
|
||||
|
||||
@@ -1012,6 +1012,15 @@ impl Program {
|
||||
}
|
||||
}
|
||||
log::trace!("Halt auto_commit {}", self.auto_commit);
|
||||
let connection = self
|
||||
.connection
|
||||
.upgrade()
|
||||
.expect("only weak ref to connection?");
|
||||
let current_state = connection.transaction_state.borrow().clone();
|
||||
if current_state == TransactionState::Read {
|
||||
pager.end_read_tx()?;
|
||||
return Ok(StepResult::Done);
|
||||
}
|
||||
return if self.auto_commit {
|
||||
match pager.end_tx() {
|
||||
Ok(crate::storage::wal::CheckpointStatus::IO) => Ok(StepResult::IO),
|
||||
|
||||
Reference in New Issue
Block a user