From 8fe073324f5806c229065b22c8d12a35b9c42e98 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Tue, 5 Feb 2019 10:27:40 -0800 Subject: [PATCH] BYTES_READ stats miscount for NotFound cases (#4938) Summary: In NotFound cases, stats BYTES_READ and perf_context.get_read_bytes is still be increased. The amount increased will be whatever size of the string or PinnableSlice that users passed in as the output data structure. This is wrong. Fix this by not increasing these two counters. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4938 Differential Revision: D13908963 Pulled By: siying fbshipit-source-id: 60bce42e4fbb9862bba3da36dbc27b2963ea6162 --- db/db_impl.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index ba9d7ff70..b7a33fb6c 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1319,10 +1319,13 @@ Status DBImpl::GetImpl(const ReadOptions& read_options, ReturnAndCleanupSuperVersion(cfd, sv); RecordTick(stats_, NUMBER_KEYS_READ); - size_t size = pinnable_val->size(); - RecordTick(stats_, BYTES_READ, size); + size_t size = 0; + if (s.ok()) { + size = pinnable_val->size(); + RecordTick(stats_, BYTES_READ, size); + PERF_COUNTER_ADD(get_read_bytes, size); + } MeasureTime(stats_, BYTES_PER_READ, size); - PERF_COUNTER_ADD(get_read_bytes, size); } return s; }