diff --git a/crates/tranquil-store/Cargo.toml b/crates/tranquil-store/Cargo.toml index e73e495..8c73dce 100644 --- a/crates/tranquil-store/Cargo.toml +++ b/crates/tranquil-store/Cargo.toml @@ -46,6 +46,7 @@ test-harness = ["dep:tempfile"] jemalloc = ["dep:tikv-jemallocator"] gauntlet-cli = ["test-harness", "dep:clap", "dep:toml", "dep:tracing-subscriber", "jemalloc"] gauntlet-jemalloc-prof = [] +skip-fsync = [] [[bin]] name = "tranquil-gauntlet" diff --git a/crates/tranquil-store/src/io.rs b/crates/tranquil-store/src/io.rs index a9a57e6..eceed66 100644 --- a/crates/tranquil-store/src/io.rs +++ b/crates/tranquil-store/src/io.rs @@ -267,10 +267,16 @@ impl StorageIO for RealIO { self.lookup(id)?.write_at(buf, offset) } + #[cfg(not(feature = "skip-fsync"))] fn sync(&self, id: FileId) -> io::Result<()> { self.lookup(id)?.sync_data() } + #[cfg(feature = "skip-fsync")] + fn sync(&self, id: FileId) -> io::Result<()> { + self.lookup(id).map(|_| ()) + } + fn file_size(&self, id: FileId) -> io::Result { self.lookup(id)?.metadata().map(|m| m.len()) } @@ -291,10 +297,16 @@ impl StorageIO for RealIO { fs::create_dir_all(path) } + #[cfg(not(feature = "skip-fsync"))] fn sync_dir(&self, path: &Path) -> io::Result<()> { fs::File::open(path)?.sync_all() } + #[cfg(feature = "skip-fsync")] + fn sync_dir(&self, path: &Path) -> io::Result<()> { + fs::File::open(path).map(|_| ()) + } + fn list_dir(&self, path: &Path) -> io::Result> { fs::read_dir(path)? .map(|entry| entry.map(|e| e.path())) diff --git a/crates/tranquil-store/src/metastore/mod.rs b/crates/tranquil-store/src/metastore/mod.rs index 4f22bfb..fc97b95 100644 --- a/crates/tranquil-store/src/metastore/mod.rs +++ b/crates/tranquil-store/src/metastore/mod.rs @@ -42,6 +42,11 @@ use self::user_hash::UserHashMap; const CURRENT_FORMAT_VERSION: u64 = 3; +#[cfg(feature = "skip-fsync")] +const METASTORE_PERSIST_MODE: fjall::PersistMode = fjall::PersistMode::Buffer; +#[cfg(not(feature = "skip-fsync"))] +const METASTORE_PERSIST_MODE: fjall::PersistMode = fjall::PersistMode::SyncData; + #[derive(Debug, Clone)] pub struct MetastoreConfig { pub cache_size_bytes: u64, @@ -243,14 +248,14 @@ impl Metastore { repo_data.remove(records::record_by_cid_built_key().as_slice())?; Self::migrate_blob_ownership(db, repo_data)?; repo_data.insert(version_key, version_bytes)?; - db.persist(fjall::PersistMode::SyncData)?; + db.persist(METASTORE_PERSIST_MODE)?; Ok(()) } } } None => { repo_data.insert(version_key, version_bytes)?; - db.persist(fjall::PersistMode::SyncData)?; + db.persist(METASTORE_PERSIST_MODE)?; Ok(()) } } @@ -427,7 +432,7 @@ impl Metastore { pub fn persist(&self) -> Result<(), MetastoreError> { self.db - .persist(fjall::PersistMode::SyncData) + .persist(METASTORE_PERSIST_MODE) .map_err(MetastoreError::Fjall) } diff --git a/justfile b/justfile index be34371..2faa600 100644 --- a/justfile +++ b/justfile @@ -98,7 +98,7 @@ test-store-asan: test-unit: SQLX_OFFLINE=true cargo test --test dpop_unit --test validation_edge_cases --test scope_edge_cases -store_test := "SQLX_OFFLINE=true TRANQUIL_TEST_BACKEND=store TRANQUIL_PDS_ALLOW_INSECURE_SECRETS=1 DISABLE_RATE_LIMITING=1 TRANQUIL_LEXICON_OFFLINE=1 SKIP_IMPORT_VERIFICATION=true cargo nextest run -E 'not package(tranquil-store) and not binary(store_parity)'" +store_test := "SQLX_OFFLINE=true TRANQUIL_TEST_BACKEND=store TRANQUIL_PDS_ALLOW_INSECURE_SECRETS=1 DISABLE_RATE_LIMITING=1 TRANQUIL_LEXICON_OFFLINE=1 SKIP_IMPORT_VERIFICATION=true cargo nextest run --features tranquil-store/skip-fsync -E 'not package(tranquil-store) and not binary(store_parity)'" test-auth: {{store_test}} --test oauth --test oauth_lifecycle --test oauth_scopes --test oauth_security --test jwt_security --test session_management --test change_password --test password_reset