Skip to content

Commit

Permalink
Add DB::sync_wal to support syncing the WAL without a flush (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-readyset authored Oct 23, 2023
1 parent 1ad2e56 commit b488c8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion librocksdb-sys/rocksdb
Submodule rocksdb updated 2 files
+4 −0 db/c.cc
+3 −0 include/rocksdb/c.h
16 changes: 16 additions & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,22 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
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 {
Expand Down

0 comments on commit b488c8e

Please sign in to comment.