diff --git a/db/memtable.cc b/db/memtable.cc index 51b54d636..58683e2f6 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -414,7 +414,8 @@ InternalIterator* MemTable::NewIterator(const ReadOptions& read_options, FragmentedRangeTombstoneIterator* MemTable::NewRangeTombstoneIterator( const ReadOptions& read_options, SequenceNumber read_seq) { - if (read_options.ignore_range_deletions || is_range_del_table_empty_) { + if (read_options.ignore_range_deletions || + is_range_del_table_empty_.load(std::memory_order_relaxed)) { return nullptr; } auto* unfragmented_iter = new MemTableIterator( @@ -563,8 +564,8 @@ bool MemTable::Add(SequenceNumber s, ValueType type, !first_seqno_.compare_exchange_weak(cur_earliest_seqno, s)) { } } - if (is_range_del_table_empty_ && type == kTypeRangeDeletion) { - is_range_del_table_empty_ = false; + if (type == kTypeRangeDeletion) { + is_range_del_table_empty_.store(false, std::memory_order_relaxed); } UpdateOldestKeyTime(); return true; diff --git a/db/memtable.h b/db/memtable.h index aac09af40..93a4a3ea5 100644 --- a/db/memtable.h +++ b/db/memtable.h @@ -409,7 +409,7 @@ class MemTable { ConcurrentArena arena_; std::unique_ptr table_; std::unique_ptr range_del_table_; - bool is_range_del_table_empty_; + std::atomic_bool is_range_del_table_empty_; // Total data size of all data inserted std::atomic data_size_;