aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-06-09 16:23:21 +0200
committerAlex Auvolat <alex@adnab.me>2023-06-09 16:23:21 +0200
commite7e164a280dfc1c4adf9d6da6f3b2a9674eca4bd (patch)
tree610408aedb12063faf49c28de0f3071f4e1f703e /src/model
parent1e466b11eb9a3d5de2b8247fc6b635f9278bc3ac (diff)
downloadgarage-e7e164a280dfc1c4adf9d6da6f3b2a9674eca4bd.tar.gz
garage-e7e164a280dfc1c4adf9d6da6f3b2a9674eca4bd.zip
Make fsync an option for meta and data
Diffstat (limited to 'src/model')
-rw-r--r--src/model/garage.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/model/garage.rs b/src/model/garage.rs
index 0fbcf334..9b7121db 100644
--- a/src/model/garage.rs
+++ b/src/model/garage.rs
@@ -91,6 +91,11 @@ impl Garage {
// ---- Sled DB ----
#[cfg(feature = "sled")]
"sled" => {
+ if config.metadata_fsync {
+ return Err(Error::Message(format!(
+ "`metadata_fsync = true` is not supported with the Sled database engine"
+ )));
+ }
db_path.push("db");
info!("Opening Sled database at: {}", db_path.display());
let db = db::sled_adapter::sled::Config::default()
@@ -111,7 +116,11 @@ impl Garage {
let db = db::sqlite_adapter::rusqlite::Connection::open(db_path)
.and_then(|db| {
db.pragma_update(None, "journal_mode", &"WAL")?;
- db.pragma_update(None, "synchronous", &"NORMAL")?;
+ if config.metadata_fsync {
+ db.pragma_update(None, "synchronous", &"NORMAL")?;
+ } else {
+ db.pragma_update(None, "synchronous", &"OFF")?;
+ }
Ok(db)
})
.ok_or_message("Unable to open sqlite DB")?;
@@ -139,6 +148,9 @@ impl Garage {
env_builder.map_size(map_size);
unsafe {
env_builder.flag(heed::flags::Flags::MdbNoMetaSync);
+ if !config.metadata_fsync {
+ env_builder.flag(heed::flags::Flags::MdbNoSync);
+ }
}
let db = match env_builder.open(&db_path) {
Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => {
@@ -208,6 +220,7 @@ impl Garage {
let block_manager = BlockManager::new(
&db,
config.data_dir.clone(),
+ config.data_fsync,
config.compression_level,
data_rep_param,
system.clone(),