mirror of https://github.com/facebook/rocksdb.git
Introduce use_multi_cf_iterator in stress test (#12706)
Summary: Introduce `use_multi_cf_iterator`, and when it's set, use `CoalescingIterator` in `TestIterate()`. Because all the column families contain the same data in today's Stress Test, we can compare `CoalescingIterator` against any `DBIter` from any of the column families. Currently, coalescing logic verification is done by unit tests, but we can extend the stress test to support different data in different column families in the future. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12706 Test Plan: ``` python3 tools/db_crashtest.py blackbox --simple --max_key=25000000 --write_buffer_size=4194304 --use_attribute_group=0 --use_put_entity_one_in=1 --use_multi_get=1 --use_multi_cf_iterator=1 ``` **More PRs to come** - Use `AttributeGroupIterator` when both `use_multi_cf_iterator` and `use_attribute_group` are true - Support `Refresh()` in `CoalescingIterator` - Extend Stress Test to support different data in different CFs (Long-term) Reviewed By: ltamasi Differential Revision: D58020247 Pulled By: jaykorean fbshipit-source-id: 8e2483b85cf2bb0f5a9bb44851601bbf063484ec
This commit is contained in:
parent
76aa0d9ee2
commit
a901ef48f0
|
@ -255,6 +255,7 @@ DECLARE_int32(prefix_size);
|
|||
DECLARE_bool(use_merge);
|
||||
DECLARE_uint32(use_put_entity_one_in);
|
||||
DECLARE_bool(use_attribute_group);
|
||||
DECLARE_bool(use_multi_cf_iterator);
|
||||
DECLARE_bool(use_full_merge_v1);
|
||||
DECLARE_int32(sync_wal_one_in);
|
||||
DECLARE_bool(avoid_unnecessary_blocking_io);
|
||||
|
|
|
@ -958,6 +958,9 @@ DEFINE_uint32(use_put_entity_one_in, 0,
|
|||
DEFINE_bool(use_attribute_group, false,
|
||||
"If set, use the attribute_group API to put/get entities");
|
||||
|
||||
DEFINE_bool(use_multi_cf_iterator, false,
|
||||
"If set, use the multi_cf_iterator for TestIterate");
|
||||
|
||||
DEFINE_bool(use_full_merge_v1, false,
|
||||
"On true, use a merge operator that implement the deprecated "
|
||||
"version of FullMerge");
|
||||
|
|
|
@ -1425,15 +1425,28 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|||
ro.iterate_lower_bound = &lower_bound;
|
||||
}
|
||||
|
||||
std::unique_ptr<Iterator> iter;
|
||||
|
||||
if (FLAGS_use_multi_cf_iterator) {
|
||||
std::vector<ColumnFamilyHandle*> cfhs;
|
||||
cfhs.reserve(rand_column_families.size());
|
||||
for (auto cf_index : rand_column_families) {
|
||||
cfhs.emplace_back(column_families_[cf_index]);
|
||||
}
|
||||
assert(!cfhs.empty());
|
||||
iter = db_->NewCoalescingIterator(ro, cfhs);
|
||||
} else {
|
||||
ColumnFamilyHandle* const cfh = column_families_[rand_column_families[0]];
|
||||
assert(cfh);
|
||||
|
||||
std::unique_ptr<Iterator> iter(db_->NewIterator(ro, cfh));
|
||||
iter = std::unique_ptr<Iterator>(db_->NewIterator(ro, cfh));
|
||||
}
|
||||
|
||||
std::vector<std::string> key_strs;
|
||||
if (thread->rand.OneIn(16)) {
|
||||
// Generate keys close to lower or upper bound of SST files.
|
||||
key_strs = GetWhiteBoxKeys(thread, db_, cfh, rand_keys.size());
|
||||
key_strs =
|
||||
GetWhiteBoxKeys(thread, db_, column_families_[rand_column_families[0]],
|
||||
rand_keys.size());
|
||||
}
|
||||
if (key_strs.empty()) {
|
||||
// Use the random keys passed in.
|
||||
|
@ -1495,9 +1508,10 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|||
|
||||
const bool support_seek_first_or_last = expect_total_order;
|
||||
|
||||
// Write-prepared and Write-unprepared do not support Refresh() yet.
|
||||
// Write-prepared and Write-unprepared and multi-cf-iterator do not support
|
||||
// Refresh() yet.
|
||||
if (!(FLAGS_use_txn && FLAGS_txn_write_policy != 0 /* write committed */) &&
|
||||
thread->rand.OneIn(4)) {
|
||||
!FLAGS_use_multi_cf_iterator && thread->rand.OneIn(4)) {
|
||||
Status s = iter->Refresh(snapshot_guard.snapshot());
|
||||
assert(s.ok());
|
||||
op_logs += "Refresh ";
|
||||
|
|
|
@ -153,6 +153,7 @@ default_params = {
|
|||
# use_put_entity_one_in has to be the same across invocations for verification to work, hence no lambda
|
||||
"use_put_entity_one_in": random.choice([0] * 7 + [1, 5, 10]),
|
||||
"use_attribute_group": lambda: random.randint(0, 1),
|
||||
"use_multi_cf_iterator": lambda: random.randint(0, 1),
|
||||
# 999 -> use Bloom API
|
||||
"bloom_before_level": lambda: random.choice([random.randint(-1, 2), random.randint(-1, 10), 0x7fffffff - 1, 0x7fffffff]),
|
||||
"value_size_mult": 32,
|
||||
|
|
Loading…
Reference in New Issue