Skip to content

Commit

Permalink
[storage] Enable the strictest sync mode for RocksDB's WAL
Browse files Browse the repository at this point in the history
This commit enables sync mode = true for RocksDB WAL, when committing a WriteBatch.
This option isn't enabled by default.
This would increase the durability level to survive a whole machine
crush, and with the expense of (potentially) higher commit latency.
Keep in mind that the WAL writes are temporarily enabled for the main
store, up to the point that our distributed log will be responsible for
durability.
  • Loading branch information
igalshilman committed Dec 1, 2023
1 parent 2519b5d commit 611d4b1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/storage-rocksdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use futures::{ready, FutureExt, Stream};
use futures_util::future::ok;
use futures_util::StreamExt;
use restate_storage_api::{GetFuture, GetStream, PutFuture, Storage, StorageError, Transaction};
use rocksdb::BlockBasedOptions;
use rocksdb::Cache;
use rocksdb::ColumnFamily;
use rocksdb::DBCompressionType;
Expand All @@ -44,6 +43,7 @@ use rocksdb::PrefixRange;
use rocksdb::ReadOptions;
use rocksdb::SingleThreaded;
use rocksdb::WriteBatch;
use rocksdb::{BlockBasedOptions, WriteOptions};
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
Expand Down Expand Up @@ -599,7 +599,9 @@ impl<'a> Transaction for RocksDBTransaction<'a> {
// for now we always use the WAL when committing the write batch,
// but once we will have the Raft log persisted else where, this becomes
// only needed during a checkpoint operation.
db.write(write_batch)
let mut opts = WriteOptions::default();
opts.set_sync(true);
db.write_opt(write_batch, &opts)
.map_err(|error| StorageError::Generic(error.into()))
};
tokio::task::spawn_blocking(f)
Expand Down

0 comments on commit 611d4b1

Please sign in to comment.