Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DBImpl::has_unpersisted_data_ atomic #1869

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void DBImpl::CancelAllBackgroundWork(bool wait) {
"Shutdown: canceling all background work");

if (!shutting_down_.load(std::memory_order_acquire) &&
has_unpersisted_data_ &&
has_unpersisted_data_.load(std::memory_order_relaxed) &&
!mutable_db_options_.avoid_flush_during_shutdown) {
for (auto cfd : *versions_->GetColumnFamilySet()) {
if (!cfd->IsDropped() && !cfd->mem()->IsEmpty()) {
Expand Down Expand Up @@ -4036,8 +4036,8 @@ Status DBImpl::GetImpl(const ReadOptions& read_options,
LookupKey lkey(key, snapshot);
PERF_TIMER_STOP(get_snapshot_time);

bool skip_memtable =
(read_options.read_tier == kPersistedTier && has_unpersisted_data_);
bool skip_memtable = (read_options.read_tier == kPersistedTier &&
has_unpersisted_data_.load(std::memory_order_relaxed));
bool done = false;
if (!skip_memtable) {
if (sv->mem->Get(lkey, value, &s, &merge_context, &range_del_agg,
Expand Down Expand Up @@ -4142,7 +4142,8 @@ std::vector<Status> DBImpl::MultiGet(
auto mgd = mgd_iter->second;
auto super_version = mgd->super_version;
bool skip_memtable =
(read_options.read_tier == kPersistedTier && has_unpersisted_data_);
(read_options.read_tier == kPersistedTier &&
has_unpersisted_data_.load(std::memory_order_relaxed));
bool done = false;
if (!skip_memtable) {
if (super_version->mem->Get(lkey, value, &s, &merge_context,
Expand Down Expand Up @@ -4875,7 +4876,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
PERF_TIMER_STOP(write_pre_and_post_process_time);

if (write_options.disableWAL) {
has_unpersisted_data_ = true;
has_unpersisted_data_.store(true, std::memory_order_relaxed);
}

uint64_t log_size = 0;
Expand Down
3 changes: 1 addition & 2 deletions db/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,7 @@ class DBImpl : public DB {
// A flag indicating whether the current rocksdb database has any
// data that is not yet persisted into either WAL or SST file.
// Used when disableWAL is true.
bool has_unpersisted_data_;

std::atomic<bool> has_unpersisted_data_;

// if an attempt was made to flush all column families that
// the oldest log depends on but uncommited data in the oldest
Expand Down