Minor cleanup

This commit is contained in:
Peter Dillinger 2019-12-12 09:33:35 -08:00
parent 77b6870769
commit 4fda92684a
2 changed files with 15 additions and 17 deletions

View File

@ -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<const Snapshot,
std::function<void(const Snapshot*)>> snapshot(
db_->GetSnapshot(),
[this](const Snapshot* s) {
db_->ReleaseSnapshot(s);
});
std::unique_ptr<const Snapshot, std::function<void(const Snapshot*)>>
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<Iterator> iter(db_->NewIterator(read_opts));
TEST_SYNC_POINT("SnapshotPreventsDroppedKeysInIMMemTables:AfterNewIterator");
TEST_SYNC_POINT("SnapshotPreventsDroppedKeysInImmMemTables:AfterNewIterator");
iter->SeekToFirst();
ASSERT_TRUE(iter->Valid());

View File

@ -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<FragmentedRangeTombstoneIterator> 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();