diff --git a/db/db_range_del_test.cc b/db/db_range_del_test.cc index 9c2a12d63..f2953a746 100644 --- a/db/db_range_del_test.cc +++ b/db/db_range_del_test.cc @@ -1427,7 +1427,7 @@ TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeys) { db_->ReleaseSnapshot(snapshot); } -TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeysInIMMemTables) { +TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeysInImmMemTables) { const int kFileBytes = 1 << 20; Options options = CurrentOptions(); @@ -1438,19 +1438,16 @@ TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeysInIMMemTables) { // block flush thread -> pin immtables in memory SyncPoint::GetInstance()->DisableProcessing(); - rocksdb::SyncPoint::GetInstance()->LoadDependency({ - {"SnapshotPreventsDroppedKeysInIMMemTables:AfterNewIterator", - "DBImpl::BGWorkFlush"}, + SyncPoint::GetInstance()->LoadDependency({ + {"SnapshotPreventsDroppedKeysInImmMemTables:AfterNewIterator", + "DBImpl::BGWorkFlush"}, }); - rocksdb::SyncPoint::GetInstance()->EnableProcessing(); + SyncPoint::GetInstance()->EnableProcessing(); ASSERT_OK(Put(Key(0), "a")); - std::unique_ptr> snapshot( - db_->GetSnapshot(), - [this](const Snapshot* s) { - db_->ReleaseSnapshot(s); - }); + std::unique_ptr> + snapshot(db_->GetSnapshot(), + [this](const Snapshot* s) { db_->ReleaseSnapshot(s); }); ASSERT_OK(db_->DeleteRange(WriteOptions(), db_->DefaultColumnFamily(), Key(0), Key(10))); @@ -1461,7 +1458,7 @@ TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeysInIMMemTables) { read_opts.snapshot = snapshot.get(); std::unique_ptr iter(db_->NewIterator(read_opts)); - TEST_SYNC_POINT("SnapshotPreventsDroppedKeysInIMMemTables:AfterNewIterator"); + TEST_SYNC_POINT("SnapshotPreventsDroppedKeysInImmMemTables:AfterNewIterator"); iter->SeekToFirst(); ASSERT_TRUE(iter->Valid()); diff --git a/db/memtable_list.cc b/db/memtable_list.cc index 1c0ca0b9f..93ab2e77c 100644 --- a/db/memtable_list.cc +++ b/db/memtable_list.cc @@ -186,13 +186,14 @@ Status MemTableListVersion::AddRangeTombstoneIterators( const ReadOptions& read_opts, Arena* /*arena*/, RangeDelAggregator* range_del_agg) { assert(range_del_agg != nullptr); - SequenceNumber snapshot = kMaxSequenceNumber; - if (read_opts.snapshot != nullptr) { - snapshot = read_opts.snapshot->GetSequenceNumber(); - } + // Except for snapshot read, using kMaxSequenceNumber is OK because these + // are immutable memtables. + SequenceNumber read_seq = read_opts.snapshot != nullptr + ? read_opts.snapshot->GetSequenceNumber() + : kMaxSequenceNumber; for (auto& m : memlist_) { std::unique_ptr range_del_iter( - m->NewRangeTombstoneIterator(read_opts, snapshot /* read_seq */)); + m->NewRangeTombstoneIterator(read_opts, read_seq)); range_del_agg->AddTombstones(std::move(range_del_iter)); } return Status::OK();