core: Wrap Connection::wal_auto_checkpoint_disabled with AtomicBool

This commit is contained in:
Pekka Enberg
2025-09-23 14:03:24 +03:00
parent aa95cb24ea
commit 042a8dd031
2 changed files with 10 additions and 5 deletions

View File

@@ -509,7 +509,7 @@ impl Database {
_shared_cache: false,
cache_size: AtomicI32::new(default_cache_size),
page_size: AtomicU16::new(page_size.get_raw()),
wal_auto_checkpoint_disabled: Cell::new(false),
wal_auto_checkpoint_disabled: AtomicBool::new(false),
capture_data_changes: RefCell::new(CaptureDataChangesMode::Off),
closed: Cell::new(false),
attached_databases: RefCell::new(DatabaseCatalog::new()),
@@ -998,7 +998,7 @@ pub struct Connection {
page_size: AtomicU16,
/// Disable automatic checkpoint behaviour when DB is shutted down or WAL reach certain size
/// Client still can manually execute PRAGMA wal_checkpoint(...) commands
wal_auto_checkpoint_disabled: Cell<bool>,
wal_auto_checkpoint_disabled: AtomicBool,
capture_data_changes: RefCell<CaptureDataChangesMode>,
closed: Cell<bool>,
/// Attached databases
@@ -1652,13 +1652,18 @@ impl Connection {
{
self.pager
.read()
.checkpoint_shutdown(self.wal_auto_checkpoint_disabled.get())?;
.checkpoint_shutdown(self.is_wal_auto_checkpoint_disabled())?;
};
Ok(())
}
pub fn wal_auto_checkpoint_disable(&self) {
self.wal_auto_checkpoint_disabled.set(true);
self.wal_auto_checkpoint_disabled
.store(true, Ordering::SeqCst);
}
pub fn is_wal_auto_checkpoint_disabled(&self) -> bool {
self.wal_auto_checkpoint_disabled.load(Ordering::SeqCst)
}
pub fn last_insert_rowid(&self) -> i64 {

View File

@@ -1145,7 +1145,7 @@ impl Pager {
return Ok(IOResult::Done(PagerCommitResult::Rollback));
}
let commit_status = return_if_io!(self.commit_dirty_pages(
connection.wal_auto_checkpoint_disabled.get(),
connection.is_wal_auto_checkpoint_disabled(),
connection.get_sync_mode(),
connection.get_data_sync_retry()
));