Merge 'mvcc: Disable automatic checkpointing by default' from Pekka Enberg

MVCC checkpointing currently prevents concurrent writes so disable it by
default while we work on it.

Closes #3631
This commit is contained in:
Pekka Enberg
2025-10-08 17:09:37 +03:00
committed by GitHub
5 changed files with 20 additions and 18 deletions

View File

@@ -2360,7 +2360,7 @@ impl Connection {
*self.mv_tx.read()
}
pub(crate) fn set_mvcc_checkpoint_threshold(&self, threshold: u64) -> Result<()> {
pub(crate) fn set_mvcc_checkpoint_threshold(&self, threshold: i64) -> Result<()> {
match self.db.mv_store.as_ref() {
Some(mv_store) => {
mv_store.set_checkpoint_threshold(threshold);
@@ -2370,7 +2370,7 @@ impl Connection {
}
}
pub(crate) fn mvcc_checkpoint_threshold(&self) -> Result<u64> {
pub(crate) fn mvcc_checkpoint_threshold(&self) -> Result<i64> {
match self.db.mv_store.as_ref() {
Some(mv_store) => Ok(mv_store.checkpoint_threshold()),
None => Err(LimboError::InternalError("MVCC not enabled".into())),

View File

@@ -2025,11 +2025,11 @@ impl<Clock: LogicalClock> MvStore<Clock> {
Ok(true)
}
pub fn set_checkpoint_threshold(&self, threshold: u64) {
pub fn set_checkpoint_threshold(&self, threshold: i64) {
self.storage.set_checkpoint_threshold(threshold)
}
pub fn checkpoint_threshold(&self) -> u64 {
pub fn checkpoint_threshold(&self) -> i64 {
self.storage.checkpoint_threshold()
}
}

View File

@@ -12,17 +12,14 @@ use std::sync::{Arc, RwLock};
use crate::File;
pub const DEFAULT_LOG_CHECKPOINT_THRESHOLD: u64 = 1024 * 1024 * 8; // 8 MiB as default to mimic
// 2000 pages in sqlite which is
// pretty much equal to
// 8MiB if page_size ==
// 4096 bytes
pub const DEFAULT_LOG_CHECKPOINT_THRESHOLD: i64 = -1; // Disabled by default
pub struct LogicalLog {
pub file: Arc<dyn File>,
pub offset: u64,
/// Size at which we start performing a checkpoint on the logical log.
checkpoint_threshold: u64,
/// Set to -1 to disable automatic checkpointing.
checkpoint_threshold: i64,
}
/// Log's Header, this will be the 64 bytes in any logical log file.
@@ -229,14 +226,17 @@ impl LogicalLog {
}
pub fn should_checkpoint(&self) -> bool {
self.offset >= self.checkpoint_threshold
if self.checkpoint_threshold < 0 {
return false;
}
self.offset >= self.checkpoint_threshold as u64
}
pub fn set_checkpoint_threshold(&mut self, threshold: u64) {
pub fn set_checkpoint_threshold(&mut self, threshold: i64) {
self.checkpoint_threshold = threshold;
}
pub fn checkpoint_threshold(&self) -> u64 {
pub fn checkpoint_threshold(&self) -> i64 {
self.checkpoint_threshold
}
}

View File

@@ -44,11 +44,11 @@ impl Storage {
self.logical_log.read().should_checkpoint()
}
pub fn set_checkpoint_threshold(&self, threshold: u64) {
pub fn set_checkpoint_threshold(&self, threshold: i64) {
self.logical_log.write().set_checkpoint_threshold(threshold)
}
pub fn checkpoint_threshold(&self) -> u64 {
pub fn checkpoint_threshold(&self) -> i64 {
self.logical_log.read().checkpoint_threshold()
}
}

View File

@@ -371,8 +371,10 @@ fn update_pragma(
}
PragmaName::MvccCheckpointThreshold => {
let threshold = match parse_signed_number(&value)? {
Value::Integer(size) if size > 0 => size as u64,
_ => bail_parse_error!("mvcc_checkpoint_threshold must be a positive integer"),
Value::Integer(size) if size >= -1 => size,
_ => bail_parse_error!(
"mvcc_checkpoint_threshold must be -1, 0, or a positive integer"
),
};
connection.set_mvcc_checkpoint_threshold(threshold)?;
@@ -695,7 +697,7 @@ fn query_pragma(
PragmaName::MvccCheckpointThreshold => {
let threshold = connection.mvcc_checkpoint_threshold()?;
let register = program.alloc_register();
program.emit_int(threshold as i64, register);
program.emit_int(threshold, register);
program.emit_result_row(register, 1);
program.add_pragma_result_column(pragma.to_string());
Ok((program, TransactionMode::None))