diff --git a/db/db_impl/db_impl_open.cc b/db/db_impl/db_impl_open.cc index 199a066b3..3f5c3b29d 100644 --- a/db/db_impl/db_impl_open.cc +++ b/db/db_impl/db_impl_open.cc @@ -2080,9 +2080,15 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname, impl); LogFlush(impl->immutable_db_options_.info_log); if (!impl->WALBufferIsEmpty()) { - impl->FlushWAL(true /* sync */); + s = impl->FlushWAL(false); + if (s.ok()) { + // Sync is needed otherwise WAL buffered data might get lost after a + // power reset. + log::Writer* log_writer = impl->logs_.back().writer; + s = log_writer->file()->Sync(impl->immutable_db_options_.use_fsync); + } } - if (!persist_options_status.ok()) { + if (s.ok() && !persist_options_status.ok()) { s = Status::IOError( "DB::Open() failed --- Unable to persist Options file", persist_options_status.ToString()); diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index aed00e8d5..4f2ce8b92 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -836,7 +836,7 @@ void StressTest::OperateDb(ThreadState* thread) { if (thread->rand.OneInOpt(FLAGS_manual_wal_flush_one_in)) { bool sync = thread->rand.OneIn(2) ? true : false; Status s = db_->FlushWAL(sync); - if (!s.ok()) { + if (!s.ok() && !(sync && s.IsNotSupported())) { fprintf(stderr, "FlushWAL(sync=%s) failed: %s\n", (sync ? "true" : "false"), s.ToString().c_str()); }