From 9079895aaeaa8975e7d6bd6f1dc1d23cc09d5956 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 28 Oct 2022 17:03:44 -0700 Subject: [PATCH] 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 --- db/memtable.cc | 3 ++- table/block_based/block_based_table_builder.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db/memtable.cc b/db/memtable.cc index 9099d5e39..369627a33 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -784,7 +784,8 @@ Status MemTable::Add(SequenceNumber s, ValueType type, std::memory_order_relaxed); data_size_.store(data_size_.load(std::memory_order_relaxed) + encoded_len, 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, std::memory_order_relaxed); } diff --git a/table/block_based/block_based_table_builder.cc b/table/block_based/block_based_table_builder.cc index d623ac264..c79a44830 100644 --- a/table/block_based/block_based_table_builder.cc +++ b/table/block_based/block_based_table_builder.cc @@ -1010,7 +1010,8 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) { r->props.num_entries++; r->props.raw_key_size += key.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++; } else if (value_type == kTypeRangeDeletion) { r->props.num_deletions++;