diff --git a/librocksdb-sys/rocksdb b/librocksdb-sys/rocksdb index 06f13144a..5b4c37e67 160000 --- a/librocksdb-sys/rocksdb +++ b/librocksdb-sys/rocksdb @@ -1 +1 @@ -Subproject commit 06f13144a44372d9f27d428a66aaf27c5cb8b03f +Subproject commit 5b4c37e67666008004bfe87fc7bb009756c64527 diff --git a/src/db.rs b/src/db.rs index 1cd44ac9d..91423e1af 100644 --- a/src/db.rs +++ b/src/db.rs @@ -886,6 +886,22 @@ impl DBCommon { Ok(()) } + /// Ensure all WAL writes have been synced to storage, so that (assuming OS + /// and hardware support) data will survive power loss. This function does + /// not imply flush_wal, so flush_wal(true) is recommended if using + /// manual_wal_flush=true. Currently only works if allow_mmap_writes = false + /// in Options. + /// + /// Note that write() followed by sync_wal() is not exactly the same as write() + /// with sync=true: in the latter case the changes won't be visible until the + /// sync is done. + pub fn sync_wal(&self) -> Result<(), Error> { + unsafe { + ffi_try!(ffi::rocksdb_sync_wal(self.inner.inner())); + } + Ok(()) + } + /// Flushes database memtables to SST files on the disk. pub fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error> { unsafe {