Assert keys/values pinned by range deletion meta-block iterators

Summary:
`RangeDelAggregator` holds the pointers returned by `BlockIter::key()` and `BlockIter::value()` so requires the data to which they point is pinned. `BlockIter::key()` points into block memory and is guaranteed to be pinned if and only if prefix encoding is disabled (or, equivalently, restart interval is set to one). I think `BlockIter::value()` is always pinned. Added an assert for these and removed the wrong TODO about increasing restart interval, which would enable key prefix encoding and break the assertion.
Closes https://github.com/facebook/rocksdb/pull/3875

Differential Revision: D8063667

Pulled By: ajkr

fbshipit-source-id: 60b5ebcc0cdd610dd6aad9e74a23378793672c41
main
Andrew Kryczka 6 years ago committed by Facebook Github Bot
parent e410501eeb
commit 7b655214d2
  1. 4
      db/range_del_aggregator.cc
  2. 2
      table/block_based_table_builder.cc
  3. 3
      util/testutil.h

@ -195,6 +195,10 @@ Status RangeDelAggregator::AddTombstones(
input->SeekToFirst();
bool first_iter = true;
while (input->Valid()) {
// The tombstone map holds slices into the iterator's memory. This assert
// ensures pinning the iterator also pins the keys/values.
assert(input->IsKeyPinned() && input->IsValuePinned());
if (first_iter) {
if (rep_ == nullptr) {
InitRep({upper_bound_});

@ -300,7 +300,7 @@ struct BlockBasedTableBuilder::Rep {
: 0),
data_block(table_options.block_restart_interval,
table_options.use_delta_encoding),
range_del_block(1), // TODO(andrewkr): restart_interval unnecessary
range_del_block(1 /* block_restart_interval */),
internal_prefix_transform(_ioptions.prefix_extractor),
compression_type(_compression_type),
compression_opts(_compression_opts),

@ -179,6 +179,9 @@ class VectorIterator : public InternalIterator {
virtual Status status() const override { return Status::OK(); }
virtual bool IsKeyPinned() const override { return true; }
virtual bool IsValuePinned() const override { return true; }
private:
std::vector<std::string> keys_;
std::vector<std::string> values_;

Loading…
Cancel
Save