always drop tombstones compacted to bottommost level

Summary:
Problem was in bottommost compaction, when an L0->L0 compaction happened and L0 was bottommost. Then we'd preserve tombstones according to `Compaction::KeyNotExistsBeyondOutputLevel`, while zeroing seqnum according to `CompactionIterator::PrepareOutput`, thus triggering the assertion in `PrepareOutput`. To fix, we can just drop tombstones in L0->L0 when the output is "bottommost", i.e., the compaction includes the oldest L0 file and there's nothing at lower levels.
Closes https://github.com/facebook/rocksdb/pull/3085

Differential Revision: D6175742

Pulled By: ajkr

fbshipit-source-id: 8ab19a2e001496f362e9eb0a71757e2f6ecfdb3b
main
Andrew Kryczka 7 years ago committed by Facebook Github Bot
parent 84a04af9a9
commit 6a9335dbbb
  1. 11
      db/compaction.cc

@ -272,10 +272,10 @@ bool Compaction::KeyNotExistsBeyondOutputLevel(
assert(input_version_ != nullptr); assert(input_version_ != nullptr);
assert(level_ptrs != nullptr); assert(level_ptrs != nullptr);
assert(level_ptrs->size() == static_cast<size_t>(number_levels_)); assert(level_ptrs->size() == static_cast<size_t>(number_levels_));
if (cfd_->ioptions()->compaction_style == kCompactionStyleLevel) { if (bottommost_level_) {
if (output_level_ == 0) { return true;
return false; } else if (output_level_ != 0 &&
} cfd_->ioptions()->compaction_style == kCompactionStyleLevel) {
// Maybe use binary search to find right entry instead of linear search? // Maybe use binary search to find right entry instead of linear search?
const Comparator* user_cmp = cfd_->user_comparator(); const Comparator* user_cmp = cfd_->user_comparator();
for (int lvl = output_level_ + 1; lvl < number_levels_; lvl++) { for (int lvl = output_level_ + 1; lvl < number_levels_; lvl++) {
@ -295,9 +295,8 @@ bool Compaction::KeyNotExistsBeyondOutputLevel(
} }
} }
return true; return true;
} else {
return bottommost_level_;
} }
return false;
} }
// Mark (or clear) each file that is being compacted // Mark (or clear) each file that is being compacted

Loading…
Cancel
Save