Compare commits

...

11 Commits

Author SHA1 Message Date
Peter Dillinger
4fda92684a Minor cleanup 2019-12-12 09:33:35 -08:00
奏之章
77b6870769
Merge 5c02676461 into e1dfe80fe0 2019-12-12 08:09:05 -08:00
奏之章
5c02676461
Merge branch 'master' into fix-range-deletion-bug 2019-12-09 22:02:10 +08:00
奏之章
73cd3da055
Merge branch 'master' into fix-range-deletion-bug 2019-12-04 15:39:56 +08:00
奏之章
da5c117dd8
Merge branch 'master' into fix-range-deletion-bug 2019-11-28 12:06:48 +08:00
奏之章
5a81a48ba9
Merge branch 'master' into fix-range-deletion-bug 2019-11-27 10:23:02 +08:00
奏之章
d21bd42116
Merge branch 'master' into fix-range-deletion-bug 2019-11-25 11:40:49 +08:00
奏之章
8020306d35 Refactor SnapshotPreventsDroppedKeysInIMMemTables 2019-11-25 11:28:39 +08:00
奏之章
b01e9b52ea Remove comment 2019-11-21 15:38:49 +08:00
奏之章
1db81809d5 Fix RangeDeletion Snapshot bug 2019-11-21 15:23:16 +08:00
Jim Lin
a752fe311d add SnapshotPreventsDroppedKeysInIMMemTables test 2019-11-21 15:09:50 +08:00
2 changed files with 47 additions and 3 deletions

View File

@ -1427,6 +1427,47 @@ TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeys) {
db_->ReleaseSnapshot(snapshot);
}
TEST_F(DBRangeDelTest, SnapshotPreventsDroppedKeysInImmMemTables) {
const int kFileBytes = 1 << 20;
Options options = CurrentOptions();
options.compression = kNoCompression;
options.disable_auto_compactions = true;
options.target_file_size_base = kFileBytes;
Reopen(options);
// block flush thread -> pin immtables in memory
SyncPoint::GetInstance()->DisableProcessing();
SyncPoint::GetInstance()->LoadDependency({
{"SnapshotPreventsDroppedKeysInImmMemTables:AfterNewIterator",
"DBImpl::BGWorkFlush"},
});
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); });
ASSERT_OK(db_->DeleteRange(WriteOptions(), db_->DefaultColumnFamily(), Key(0),
Key(10)));
ASSERT_OK(dbfull()->TEST_SwitchMemtable());
ReadOptions read_opts;
read_opts.snapshot = snapshot.get();
std::unique_ptr<Iterator> iter(db_->NewIterator(read_opts));
TEST_SYNC_POINT("SnapshotPreventsDroppedKeysInImmMemTables:AfterNewIterator");
iter->SeekToFirst();
ASSERT_TRUE(iter->Valid());
ASSERT_EQ(Key(0), iter->key());
iter->Next();
ASSERT_FALSE(iter->Valid());
}
TEST_F(DBRangeDelTest, RangeTombstoneWrittenToMinimalSsts) {
// Adapted from
// https://github.com/cockroachdb/cockroach/blob/de8b3ea603dd1592d9dc26443c2cc92c356fbc2f/pkg/storage/engine/rocksdb_test.go#L1267-L1398.

View File

@ -186,11 +186,14 @@ Status MemTableListVersion::AddRangeTombstoneIterators(
const ReadOptions& read_opts, Arena* /*arena*/,
RangeDelAggregator* range_del_agg) {
assert(range_del_agg != nullptr);
// 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_) {
// Using kMaxSequenceNumber is OK because these are immutable memtables.
std::unique_ptr<FragmentedRangeTombstoneIterator> range_del_iter(
m->NewRangeTombstoneIterator(read_opts,
kMaxSequenceNumber /* read_seq */));
m->NewRangeTombstoneIterator(read_opts, read_seq));
range_del_agg->AddTombstones(std::move(range_del_iter));
}
return Status::OK();