Make sure assert(false) handles failures too (#7483)

Summary:
In opt mode, assertions are just no-ops. Therefore, we need to report errors instead of just doing an `assert(false)`.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/7483

Test Plan: make check

Reviewed By: anand1976

Differential Revision: D24142725

Pulled By: riversand963

fbshipit-source-id: 5629556dbe29f00dd09e30a7d5df5e6cf09ee435
This commit is contained in:
Yanqin Jin 2020-10-06 13:51:22 -07:00 committed by Facebook GitHub Bot
parent 53089038de
commit 1bcef3d83c
2 changed files with 28 additions and 7 deletions

View File

@ -996,6 +996,9 @@ Compaction* UniversalCompactionBuilder::PickCompactionToOldest(
comp_reason_print_string = "size amp";
} else {
assert(false);
comp_reason_print_string = "unknown: ";
comp_reason_print_string.append(
std::to_string(static_cast<int>(compaction_reason)));
}
char file_num_buf[256];

View File

@ -384,8 +384,11 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key,
}
break;
default:
assert(false);
break;
valid_ = false;
status_ = Status::Corruption(
"Unknown value type: " +
std::to_string(static_cast<unsigned int>(ikey_.type)));
return false;
}
}
} else {
@ -556,7 +559,11 @@ bool DBIter::MergeValuesNewToOld() {
valid_ = false;
return false;
} else {
assert(false);
valid_ = false;
status_ = Status::Corruption(
"Unrecognized value type: " +
std::to_string(static_cast<unsigned int>(ikey.type)));
return false;
}
}
@ -832,7 +839,11 @@ bool DBIter::FindValueForCurrentKey() {
}
break;
default:
assert(false);
valid_ = false;
status_ = Status::Corruption(
"Unknown value type: " +
std::to_string(static_cast<unsigned int>(last_key_entry_type)));
return false;
}
PERF_COUNTER_ADD(internal_key_skipped_count, 1);
@ -898,8 +909,11 @@ bool DBIter::FindValueForCurrentKey() {
is_blob_ = true;
break;
default:
assert(false);
break;
valid_ = false;
status_ = Status::Corruption(
"Unknown value type: " +
std::to_string(static_cast<unsigned int>(last_key_entry_type)));
return false;
}
if (!s.ok()) {
valid_ = false;
@ -1048,7 +1062,11 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
valid_ = false;
return false;
} else {
assert(false);
valid_ = false;
status_ = Status::Corruption(
"Unknown value type: " +
std::to_string(static_cast<unsigned int>(ikey.type)));
return false;
}
}