WriteBatch::Iterate wrongly returns Status::Corruption (#4478)
Summary: Wrong I overwrite `WriteBatch::Handler::Continue` to return _false_ at some point, I always get the `Status::Corruption` error. I don't think this check is used correctly here: The counter in `found` cannot reflect all entries in the WriteBatch when we exit the loop early. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4478 Differential Revision: D10317416 Pulled By: yiwu-arbug fbshipit-source-id: cccae3382805035f9b3239b66682b5fcbba6bb61
This commit is contained in:
parent
7e56072290
commit
ceded4535d
@ -414,8 +414,13 @@ Status WriteBatch::Iterate(Handler* handler) const {
|
|||||||
char tag = 0;
|
char tag = 0;
|
||||||
uint32_t column_family = 0; // default
|
uint32_t column_family = 0; // default
|
||||||
bool last_was_try_again = false;
|
bool last_was_try_again = false;
|
||||||
while (((s.ok() && !input.empty()) || UNLIKELY(s.IsTryAgain())) &&
|
bool handler_continue = true;
|
||||||
handler->Continue()) {
|
while (((s.ok() && !input.empty()) || UNLIKELY(s.IsTryAgain()))) {
|
||||||
|
handler_continue = handler->Continue();
|
||||||
|
if (!handler_continue) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (LIKELY(!s.IsTryAgain())) {
|
if (LIKELY(!s.IsTryAgain())) {
|
||||||
last_was_try_again = false;
|
last_was_try_again = false;
|
||||||
tag = 0;
|
tag = 0;
|
||||||
@ -583,7 +588,7 @@ Status WriteBatch::Iterate(Handler* handler) const {
|
|||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
if (found != WriteBatchInternal::Count(this)) {
|
if (handler_continue && found != WriteBatchInternal::Count(this)) {
|
||||||
return Status::Corruption("WriteBatch has wrong count");
|
return Status::Corruption("WriteBatch has wrong count");
|
||||||
} else {
|
} else {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
|
Loading…
Reference in New Issue
Block a user