diff --git a/db/db_impl.cc b/db/db_impl.cc index 27c5a998b..2be3d2359 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -201,7 +201,7 @@ DBImpl::DBImpl(const DBOptions& options, const std::string& dbname) shutting_down_(false), bg_cv_(&mutex_), logfile_number_(0), - log_dir_unsynced_(true), + log_dir_synced_(false), log_empty_(true), default_cf_handle_(nullptr), total_log_size_(0), @@ -3101,13 +3101,13 @@ Status DBImpl::Write(const WriteOptions& write_options, WriteBatch* my_batch) { } else { status = log_->file()->Sync(); } - if (status.ok() && log_dir_unsynced_) { + if (status.ok() && !log_dir_synced_) { // We only sync WAL directory the first time WAL syncing is // requested, so that in case users never turn on WAL sync, // we can avoid the disk I/O in the write code path. status = directories_.GetWalDir()->Fsync(); } - log_dir_unsynced_ = false; + log_dir_synced_ = true; } } if (status.ok()) { @@ -3250,7 +3250,7 @@ Status DBImpl::SetNewMemtableAndNewLogFile(ColumnFamilyData* cfd, lfile->SetPreallocationBlockSize( 1.1 * mutable_cf_options.write_buffer_size); new_log = new log::Writer(std::move(lfile)); - log_dir_unsynced_ = true; + log_dir_synced_ = false; } } diff --git a/db/db_impl.h b/db/db_impl.h index 24c952b1d..70fa14727 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -422,7 +422,7 @@ class DBImpl : public DB { port::CondVar bg_cv_; uint64_t logfile_number_; unique_ptr log_; - bool log_dir_unsynced_; + bool log_dir_synced_; bool log_empty_; ColumnFamilyHandleImpl* default_cf_handle_; InternalStats* default_cf_internal_stats_;