Skip to content
Snippets Groups Projects
Commit 544c3834 authored by Jason Volk's avatar Jason Volk Committed by 🥺
Browse files

add sync() to db abstraction for fsync(2).

parent d4cfee4e
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ fn open(config: &Config) -> Result<Self> ...@@ -18,6 +18,7 @@ fn open(config: &Config) -> Result<Self>
Self: Sized; Self: Sized;
fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>>; fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>>;
fn flush(&self) -> Result<()>; fn flush(&self) -> Result<()>;
fn sync(&self) -> Result<()> { Ok(()) }
fn cleanup(&self) -> Result<()> { Ok(()) } fn cleanup(&self) -> Result<()> { Ok(()) }
fn memory_usage(&self) -> Result<String> { fn memory_usage(&self) -> Result<String> {
Ok("Current database engine does not support memory usage reporting.".to_owned()) Ok("Current database engine does not support memory usage reporting.".to_owned())
......
...@@ -170,12 +170,17 @@ fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>> { ...@@ -170,12 +170,17 @@ fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>> {
} }
fn flush(&self) -> Result<()> { fn flush(&self) -> Result<()> {
debug!("Running flush_wal (no sync)");
rust_rocksdb::DBCommon::flush_wal(&self.rocks, false)?; rust_rocksdb::DBCommon::flush_wal(&self.rocks, false)?;
Ok(()) Ok(())
} }
fn sync(&self) -> Result<()> {
rust_rocksdb::DBCommon::flush_wal(&self.rocks, true)?;
Ok(())
}
fn memory_usage(&self) -> Result<String> { fn memory_usage(&self) -> Result<String> {
let stats = rust_rocksdb::perf::get_memory_usage_stats(Some(&[&self.rocks]), Some(&[&self.cache]))?; let stats = rust_rocksdb::perf::get_memory_usage_stats(Some(&[&self.rocks]), Some(&[&self.cache]))?;
Ok(format!( Ok(format!(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment