diff --git a/db/write_batch.cc b/db/write_batch.cc index 295fba22e..3fcee08e4 100644 --- a/db/write_batch.cc +++ b/db/write_batch.cc @@ -414,8 +414,13 @@ Status WriteBatch::Iterate(Handler* handler) const { char tag = 0; uint32_t column_family = 0; // default bool last_was_try_again = false; - while (((s.ok() && !input.empty()) || UNLIKELY(s.IsTryAgain())) && - handler->Continue()) { + bool handler_continue = true; + while (((s.ok() && !input.empty()) || UNLIKELY(s.IsTryAgain()))) { + handler_continue = handler->Continue(); + if (!handler_continue) { + break; + } + if (LIKELY(!s.IsTryAgain())) { last_was_try_again = false; tag = 0; @@ -583,7 +588,7 @@ Status WriteBatch::Iterate(Handler* handler) const { if (!s.ok()) { return s; } - if (found != WriteBatchInternal::Count(this)) { + if (handler_continue && found != WriteBatchInternal::Count(this)) { return Status::Corruption("WriteBatch has wrong count"); } else { return Status::OK();