db_stress rolling active window
Summary: Support a window of `active_width` keys that rolls through `[0, max_key)` over the duration of the test. Operations only affect keys inside the window. This gives us the ability to detect L0->L0 deletion bug (#2722). Closes https://github.com/facebook/rocksdb/pull/2739 Differential Revision: D5628555 Pulled By: ajkr fbshipit-source-id: 9cb2d8f4ab1a7c73f7797b8e19f7094970ea8749
This commit is contained in:
parent
dfa6c23c4b
commit
7aa96db7a2
@ -93,6 +93,13 @@ DEFINE_int64(max_key, 1 * KB* KB,
|
||||
|
||||
DEFINE_int32(column_families, 10, "Number of column families");
|
||||
|
||||
DEFINE_int64(
|
||||
active_width, 0,
|
||||
"Number of keys in active span of the key-range at any given time. The "
|
||||
"span begins with its left endpoint at key 0, gradually moves rightwards, "
|
||||
"and ends with its right endpoint at max_key. If set to 0, active_width "
|
||||
"will be sanitized to be equal to max_key.");
|
||||
|
||||
// TODO(noetzli) Add support for single deletes
|
||||
DEFINE_bool(test_batches_snapshots, false,
|
||||
"If set, the test uses MultiGet(), MultiPut() and MultiDelete()"
|
||||
@ -1727,7 +1734,11 @@ class StressTest {
|
||||
}
|
||||
#endif // !ROCKSDB_LITE
|
||||
|
||||
long rand_key = thread->rand.Next() % max_key;
|
||||
const double completed_ratio =
|
||||
static_cast<double>(i) / FLAGS_ops_per_thread;
|
||||
const int64_t base_key = static_cast<int64_t>(
|
||||
completed_ratio * (FLAGS_max_key - FLAGS_active_width));
|
||||
long rand_key = base_key + thread->rand.Next() % FLAGS_active_width;
|
||||
int rand_column_family = thread->rand.Next() % FLAGS_column_families;
|
||||
std::string keystr = Key(rand_key);
|
||||
Slice key = keystr;
|
||||
@ -2433,6 +2444,12 @@ int main(int argc, char** argv) {
|
||||
"test_batches_snapshots mode\n");
|
||||
exit(1);
|
||||
}
|
||||
if (FLAGS_active_width > FLAGS_max_key) {
|
||||
fprintf(stderr, "Error: active_width can be at most max_key\n");
|
||||
exit(1);
|
||||
} else if (FLAGS_active_width == 0) {
|
||||
FLAGS_active_width = FLAGS_max_key;
|
||||
}
|
||||
|
||||
// Choose a location for the test database if none given with --db=<path>
|
||||
if (FLAGS_db.empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user