Fix three more db_stress bugs (#5867)
Summary: Two more bug fixes in db_stress: 1. this is to complete the fix of the regression bug causing overflowing when supporting FLAGS_prefix_size = -1. 2. Fix regression bug in compare iterator itself: (1) when creating control iterator, which used the same read option as the normal iterator by mistake; (2) the logic of comparing has some problems. Fix them. (3) disable validation for lower bound now, which generated some wildly different results. Disabling it to make normal tests pass while investigating it. 3. Cleaning up snapshots in verification failure cases. Memory is leaked otherwise. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5867 Test Plan: Run "make crash_test" for a while and see at least 1 is fixed. Differential Revision: D17671712 fbshipit-source-id: 011f98ea1a72aef23e19ff28656830c78699b402
This commit is contained in:
parent
643df920d8
commit
69c4ccb970
@ -2372,6 +2372,11 @@ class StressTest {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
while (!thread->snapshot_queue.empty()) {
|
||||||
|
db_->ReleaseSnapshot(thread->snapshot_queue.front().second.snapshot);
|
||||||
|
delete thread->snapshot_queue.front().second.key_vec;
|
||||||
|
thread->snapshot_queue.pop();
|
||||||
|
}
|
||||||
|
|
||||||
thread->stats.Stop();
|
thread->stats.Stop();
|
||||||
}
|
}
|
||||||
@ -2486,8 +2491,7 @@ class StressTest {
|
|||||||
ReadOptions cmp_ro;
|
ReadOptions cmp_ro;
|
||||||
cmp_ro.snapshot = snapshot;
|
cmp_ro.snapshot = snapshot;
|
||||||
cmp_ro.total_order_seek = true;
|
cmp_ro.total_order_seek = true;
|
||||||
std::unique_ptr<Iterator> cmp_iter(
|
std::unique_ptr<Iterator> cmp_iter(db_->NewIterator(cmp_ro, cfh));
|
||||||
db_->NewIterator(readoptionscopy, cfh));
|
|
||||||
bool diverged = false;
|
bool diverged = false;
|
||||||
|
|
||||||
iter->Seek(key);
|
iter->Seek(key);
|
||||||
@ -2539,12 +2543,27 @@ class StressTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ro.iterate_lower_bound != nullptr) {
|
||||||
|
// Lower bound would create a lot of discrepency for now so disabling
|
||||||
|
// the verification for now.
|
||||||
|
*diverged = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (iter->Valid() && !cmp_iter->Valid()) {
|
if (iter->Valid() && !cmp_iter->Valid()) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Control interator is invalid but iterator has value %s seek key "
|
"Control interator is invalid but iterator has key %s seek key "
|
||||||
"%s\n",
|
"%s\n",
|
||||||
iter->key().ToString(true).c_str(),
|
iter->key().ToString(true).c_str(),
|
||||||
seek_key.ToString(true).c_str());
|
seek_key.ToString(true).c_str());
|
||||||
|
if (ro.iterate_upper_bound != nullptr) {
|
||||||
|
fprintf(stderr, "upper bound %s\n",
|
||||||
|
ro.iterate_upper_bound->ToString(true).c_str());
|
||||||
|
}
|
||||||
|
if (ro.iterate_lower_bound != nullptr) {
|
||||||
|
fprintf(stderr, "lower bound %s\n",
|
||||||
|
ro.iterate_lower_bound->ToString(true).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
*diverged = true;
|
*diverged = true;
|
||||||
} else if (cmp_iter->Valid()) {
|
} else if (cmp_iter->Valid()) {
|
||||||
@ -2582,8 +2601,8 @@ class StressTest {
|
|||||||
}
|
}
|
||||||
// Check upper or lower bounds.
|
// Check upper or lower bounds.
|
||||||
if (!*diverged) {
|
if (!*diverged) {
|
||||||
if (!iter->Valid() ||
|
if ((iter->Valid() && iter->key() != cmp_iter->key()) ||
|
||||||
(iter->key() != cmp_iter->key() &&
|
(!iter->Valid() &&
|
||||||
(ro.iterate_upper_bound == nullptr ||
|
(ro.iterate_upper_bound == nullptr ||
|
||||||
cmp->Compare(total_order_key, *ro.iterate_upper_bound) < 0) &&
|
cmp->Compare(total_order_key, *ro.iterate_upper_bound) < 0) &&
|
||||||
(ro.iterate_lower_bound == nullptr ||
|
(ro.iterate_lower_bound == nullptr ||
|
||||||
@ -3280,6 +3299,8 @@ class NonBatchedOpsStressTest : public StressTest {
|
|||||||
const int64_t keys_per_thread = max_key / shared->GetNumThreads();
|
const int64_t keys_per_thread = max_key / shared->GetNumThreads();
|
||||||
int64_t start = keys_per_thread * thread->tid;
|
int64_t start = keys_per_thread * thread->tid;
|
||||||
int64_t end = start + keys_per_thread;
|
int64_t end = start + keys_per_thread;
|
||||||
|
uint64_t prefix_to_use =
|
||||||
|
(FLAGS_prefix_size < 0) ? 1 : static_cast<size_t>(FLAGS_prefix_size);
|
||||||
if (thread->tid == shared->GetNumThreads() - 1) {
|
if (thread->tid == shared->GetNumThreads() - 1) {
|
||||||
end = max_key;
|
end = max_key;
|
||||||
}
|
}
|
||||||
@ -3298,8 +3319,7 @@ class NonBatchedOpsStressTest : public StressTest {
|
|||||||
}
|
}
|
||||||
// TODO(ljin): update "long" to uint64_t
|
// TODO(ljin): update "long" to uint64_t
|
||||||
// Reseek when the prefix changes
|
// Reseek when the prefix changes
|
||||||
if (i % (static_cast<int64_t>(1) << 8 * (8 - FLAGS_prefix_size)) ==
|
if (i % (static_cast<int64_t>(1) << 8 * (8 - prefix_to_use)) == 0) {
|
||||||
0) {
|
|
||||||
iter->Seek(Key(i));
|
iter->Seek(Key(i));
|
||||||
}
|
}
|
||||||
std::string from_db;
|
std::string from_db;
|
||||||
@ -4042,6 +4062,8 @@ class BatchedOpsStressTest : public StressTest {
|
|||||||
virtual Status TestPrefixScan(ThreadState* thread, const ReadOptions& readoptions,
|
virtual Status TestPrefixScan(ThreadState* thread, const ReadOptions& readoptions,
|
||||||
const std::vector<int>& rand_column_families,
|
const std::vector<int>& rand_column_families,
|
||||||
const std::vector<int64_t>& rand_keys) {
|
const std::vector<int64_t>& rand_keys) {
|
||||||
|
size_t prefix_to_use =
|
||||||
|
(FLAGS_prefix_size < 0) ? 7 : static_cast<size_t>(FLAGS_prefix_size);
|
||||||
std::string key_str = Key(rand_keys[0]);
|
std::string key_str = Key(rand_keys[0]);
|
||||||
Slice key = key_str;
|
Slice key = key_str;
|
||||||
auto cfh = column_families_[rand_column_families[0]];
|
auto cfh = column_families_[rand_column_families[0]];
|
||||||
@ -4056,7 +4078,7 @@ class BatchedOpsStressTest : public StressTest {
|
|||||||
Status s = Status::OK();
|
Status s = Status::OK();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
prefixes[i] += key.ToString();
|
prefixes[i] += key.ToString();
|
||||||
prefixes[i].resize(FLAGS_prefix_size);
|
prefixes[i].resize(prefix_to_use);
|
||||||
prefix_slices[i] = Slice(prefixes[i]);
|
prefix_slices[i] = Slice(prefixes[i]);
|
||||||
readoptionscopy[i] = readoptions;
|
readoptionscopy[i] = readoptions;
|
||||||
readoptionscopy[i].snapshot = snapshot;
|
readoptionscopy[i].snapshot = snapshot;
|
||||||
|
Loading…
Reference in New Issue
Block a user