From 2fa9bf2bf76018bbd639a618158e7c77d0da7107 Mon Sep 17 00:00:00 2001 From: Layamon Date: Tue, 26 Jan 2021 17:49:45 +0800 Subject: [PATCH] [reseek bugfix] add reseekdone flag --- db/db_iter.cc | 9 +++++++-- utilities/transactions/write_prepared_txn.cc | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/db/db_iter.cc b/db/db_iter.cc index 39e8a1ed4..586020968 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -429,7 +429,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping, bool prefix_check) { // greater than that, // - none of the above : saved_key_ can contain anything, it doesn't matter. uint64_t num_skipped = 0; - + bool reseek_done = false; do { if (!ParseKey(&ikey_)) { return false; @@ -457,6 +457,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping, bool prefix_check) { PERF_COUNTER_ADD(internal_key_skipped_count, 1); } else { num_skipped = 0; + reseek_done = false; switch (ikey_.type) { case kTypeDeletion: case kTypeSingleDeletion: @@ -500,6 +501,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping, bool prefix_check) { // they are hidden by this deletion. skipping = true; num_skipped = 0; + reseek_done = false; PERF_COUNTER_ADD(internal_delete_skipped_count, 1); } else { value_ = GetValue(ikey_, kTypeValueIndex); @@ -517,6 +519,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping, bool prefix_check) { // they are hidden by this deletion. skipping = true; num_skipped = 0; + reseek_done = false; PERF_COUNTER_ADD(internal_delete_skipped_count, 1); } else { // By now, we are sure the current ikey is going to yield a @@ -545,13 +548,15 @@ bool DBIter::FindNextUserEntryInternal(bool skipping, bool prefix_check) { saved_key_.SetUserKey(ikey_.user_key); skipping = false; num_skipped = 0; + reseek_done = false; } } // If we have sequentially iterated via numerous equal keys, then it's // better to seek so that we can avoid too many key comparisons. - if (num_skipped > max_skip_ && CanReseekToSkip()) { + if (num_skipped > max_skip_ && !reseek_done) { num_skipped = 0; + reseek_done = true; std::string last_key; if (skipping) { // We're looking for the next user-key but all we see are the same diff --git a/utilities/transactions/write_prepared_txn.cc b/utilities/transactions/write_prepared_txn.cc index 44f42c0a5..cfdac5f86 100644 --- a/utilities/transactions/write_prepared_txn.cc +++ b/utilities/transactions/write_prepared_txn.cc @@ -102,7 +102,6 @@ Status WritePreparedTxn::PrepareInternal() { assert(!s.ok() || seq_used != kMaxSequenceNumber); auto prepare_seq = seq_used; SetId(prepare_seq); - TEST_SYNC_POINT_CALLBACK("WritePreparedTxn::PrepareInternal::End", nullptr); return s; } -- GitLab