mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
Add wal checkpointing to startup/vacuum (#533)
This commit is contained in:
parent
8b7f196b2a
commit
8bc7afe007
|
@ -26,6 +26,15 @@ pub enum FsType {
|
||||||
Zfs = 65536,
|
Zfs = 65536,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FsType {
|
||||||
|
pub fn checkpoint_pages(&self) -> u32 {
|
||||||
|
match self {
|
||||||
|
FsType::Generic => 2048,
|
||||||
|
FsType::Zfs => 256,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct IdSqliteEntry {
|
pub struct IdSqliteEntry {
|
||||||
id: i64,
|
id: i64,
|
||||||
|
@ -1453,6 +1462,13 @@ impl IdlSqlite {
|
||||||
OperationError::SqliteError
|
OperationError::SqliteError
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
vconn
|
||||||
|
.execute_batch("PRAGMA wal_checkpoint(TRUNCATE);")
|
||||||
|
.map_err(|e| {
|
||||||
|
ladmin_error!(audit, "rusqlite wal_checkpoint error {:?}", e);
|
||||||
|
OperationError::SqliteError
|
||||||
|
})?;
|
||||||
|
|
||||||
vconn
|
vconn
|
||||||
.pragma_update(None, "journal_mode", &"DELETE")
|
.pragma_update(None, "journal_mode", &"DELETE")
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -1497,12 +1513,20 @@ impl IdlSqlite {
|
||||||
limmediate_warning!(audit, "NOTICE: db vacuum complete\n");
|
limmediate_warning!(audit, "NOTICE: db vacuum complete\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
let fstype = cfg.fstype as u32;
|
let fs_page_size = cfg.fstype as u32;
|
||||||
|
let checkpoint_pages = cfg.fstype.checkpoint_pages();
|
||||||
|
|
||||||
let manager = SqliteConnectionManager::file(cfg.path.as_str())
|
let manager = SqliteConnectionManager::file(cfg.path.as_str())
|
||||||
.with_init(move |c| {
|
.with_init(move |c| {
|
||||||
c.execute_batch(
|
c.execute_batch(
|
||||||
format!("PRAGMA page_size={}; PRAGMA journal_mode=WAL;", fstype).as_str(),
|
format!(
|
||||||
|
"PRAGMA page_size={};
|
||||||
|
PRAGMA journal_mode=WAL;
|
||||||
|
PRAGMA wal_autocheckpoint={};
|
||||||
|
PRAGMA wal_checkpoint(RESTART);",
|
||||||
|
fs_page_size, checkpoint_pages
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.with_flags(flags);
|
.with_flags(flags);
|
||||||
|
|
Loading…
Reference in a new issue