mirror of https://github.com/facebook/rocksdb.git
Flush WAL upon DB close (#12684)
Summary: **Context/Summary:** https://github.com/facebook/rocksdb/pull/12556 `avoid_sync_during_shutdown=false` missed an edge case where `manual_wal_flush == true` so WAL sync will still miss unflushed WAL. This PR fixes it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12684 Test Plan: modified UT to include this case `manual_wal_flush==true` Reviewed By: cbi42 Differential Revision: D57655861 Pulled By: hx235 fbshipit-source-id: c9f49fe260e8b38b3ea387558432dcd9a3dbec19
This commit is contained in:
parent
014368f62c
commit
733150f6aa
|
@ -628,11 +628,11 @@ Status DBImpl::CloseHelper() {
|
|||
}
|
||||
if (!mutable_db_options_.avoid_sync_during_shutdown && !logs_.empty()) {
|
||||
mutex_.Unlock();
|
||||
Status s = SyncWAL();
|
||||
Status s = FlushWAL(true /* sync */);
|
||||
mutex_.Lock();
|
||||
if (!s.ok()) {
|
||||
ROCKS_LOG_WARN(immutable_db_options_.info_log,
|
||||
"Unable to sync WALs with error -- %s",
|
||||
"Unable to flush and sync WALs with error -- %s",
|
||||
s.ToString().c_str());
|
||||
if (ret.ok()) {
|
||||
ret = s;
|
||||
|
|
|
@ -641,6 +641,7 @@ TEST_F(FaultInjectionFSTest, SyncWALDuringDBClose) {
|
|||
std::make_shared<FaultInjectionTestFS>(env_->GetFileSystem());
|
||||
std::unique_ptr<Env> env(new CompositeEnvWrapper(env_, fault_fs));
|
||||
Options options = CurrentOptions();
|
||||
options.manual_wal_flush = true;
|
||||
options.avoid_sync_during_shutdown = true;
|
||||
options.env = env.get();
|
||||
Reopen(options);
|
||||
|
|
|
@ -1265,9 +1265,10 @@ struct DBOptions {
|
|||
// Dynamically changeable through SetDBOptions() API.
|
||||
bool avoid_flush_during_shutdown = false;
|
||||
|
||||
// By default RocksDB will not sync WAL on DB close even if there are
|
||||
// unpersisted data (i.e. unsynced WAL data). This can speedup
|
||||
// DB close. Unpersisted data WILL BE LOST.
|
||||
// By default RocksDB will not flush (if `manual_wal_flush` = true) and sync
|
||||
// WAL on DB close even if there are unpersisted data (i.e. unflushed or
|
||||
// unsynced WAL data). This can speed up DB close. Unpersisted data WILL BE
|
||||
// LOST.
|
||||
//
|
||||
// DEFAULT: true
|
||||
//
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
* When `manual_wal_flush=true`, `avoid_sync_during_shutdown=false` will flush WALs before syncing them
|
Loading…
Reference in New Issue