From c62f3221698fd273b673d4f7e54eabb8329a4369 Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Tue, 8 Nov 2022 14:49:16 -0800 Subject: [PATCH] Clear saved value in DBIter::{Next, Prev} (#10934) Summary: `DBIter::saved_value_` stores the result of any `Merge` that was performed to compute the iterator's current value. This value can be ditched whenever the iterator's position is changed, and is already cleared in `Seek`, `SeekForPrev`, `SeekToFirst`, and `SeekToLast`. With the patch, it is also cleared in `Next` and `Prev`. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10934 Test Plan: `make check` Reviewed By: akankshamahajan15 Differential Revision: D41133473 Pulled By: ltamasi fbshipit-source-id: cf9e936f48151e64e455cc1664d6e9f4a03aa308 --- db/db_iter.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/db_iter.cc b/db/db_iter.cc index 6f8319910..9a1307005 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -158,6 +158,8 @@ void DBIter::Next() { local_stats_.next_count_++; if (ok && iter_.Valid()) { + ClearSavedValue(); + if (prefix_same_as_start_) { assert(prefix_extractor_ != nullptr); const Slice prefix = prefix_.GetUserKey(); @@ -636,6 +638,8 @@ void DBIter::Prev() { } } if (ok) { + ClearSavedValue(); + Slice prefix; if (prefix_same_as_start_) { assert(prefix_extractor_ != nullptr);