Fix deletion counting in memtable stats (#10886)

Summary:
Currently, a memtable's stats `num_deletes_` is incremented only if the entry is a regular delete (kTypeDeletion). We need to fix it by accounting for kTypeSingleDeletion and kTypeDeletionWithTimestamp.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10886

Test Plan: make check

Reviewed By: ltamasi

Differential Revision: D40740754

Pulled By: riversand963

fbshipit-source-id: 7bde62cd6df136585bc5bfb1c426c7a8276c08e1
main
Yanqin Jin 2 years ago committed by Facebook GitHub Bot
parent 36f5e19e33
commit 9079895aae
  1. 3
      db/memtable.cc
  2. 3
      table/block_based/block_based_table_builder.cc

@ -784,7 +784,8 @@ Status MemTable::Add(SequenceNumber s, ValueType type,
std::memory_order_relaxed); std::memory_order_relaxed);
data_size_.store(data_size_.load(std::memory_order_relaxed) + encoded_len, data_size_.store(data_size_.load(std::memory_order_relaxed) + encoded_len,
std::memory_order_relaxed); std::memory_order_relaxed);
if (type == kTypeDeletion) { if (type == kTypeDeletion || type == kTypeSingleDeletion ||
type == kTypeDeletionWithTimestamp) {
num_deletes_.store(num_deletes_.load(std::memory_order_relaxed) + 1, num_deletes_.store(num_deletes_.load(std::memory_order_relaxed) + 1,
std::memory_order_relaxed); std::memory_order_relaxed);
} }

@ -1010,7 +1010,8 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
r->props.num_entries++; r->props.num_entries++;
r->props.raw_key_size += key.size(); r->props.raw_key_size += key.size();
r->props.raw_value_size += value.size(); r->props.raw_value_size += value.size();
if (value_type == kTypeDeletion || value_type == kTypeSingleDeletion) { if (value_type == kTypeDeletion || value_type == kTypeSingleDeletion ||
value_type == kTypeDeletionWithTimestamp) {
r->props.num_deletions++; r->props.num_deletions++;
} else if (value_type == kTypeRangeDeletion) { } else if (value_type == kTypeRangeDeletion) {
r->props.num_deletions++; r->props.num_deletions++;

Loading…
Cancel
Save