Support manual flush in stress/crash tests (#4368)

Summary:
- Made stress test call `Flush()` periodically according to `--flush_one_in` flag.
- Enabled by default in crash test.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4368

Differential Revision: D9838593

Pulled By: ajkr

fbshipit-source-id: fe5a6e49b36e5ea752acc3aa8be364f8ef34d9cc
This commit is contained in:
Andrew Kryczka 2018-09-17 12:23:38 -07:00 committed by Facebook Github Bot
parent ac46790374
commit 8c25204633
2 changed files with 16 additions and 2 deletions

View File

@ -32,6 +32,7 @@ default_params = {
"destroy_db_initially": 0,
"enable_pipelined_write": lambda: random.randint(0, 1),
"expected_values_path": expected_values_file.name,
"flush_one_in": 1000000,
"max_background_compactions": 20,
"max_bytes_for_level_base": 10485760,
"max_key": 100000000,

View File

@ -412,6 +412,10 @@ DEFINE_int32(compact_range_one_in, 0,
"If non-zero, then CompactRange() will be called once for every N "
"operations on average. 0 indicates CompactRange() is disabled.");
DEFINE_int32(flush_one_in, 0,
"If non-zero, then Flush() will be called once for every N ops "
"on average. 0 indicates calls to Flush() are disabled.");
DEFINE_int32(compact_range_width, 10000,
"The width of the ranges passed to CompactRange().");
@ -1943,8 +1947,8 @@ class StressTest {
db_->CompactFiles(CompactionOptions(), random_cf, input_files,
static_cast<int>(output_level));
if (!s.ok()) {
printf("Unable to perform CompactFiles(): %s\n",
s.ToString().c_str());
fprintf(stdout, "Unable to perform CompactFiles(): %s\n",
s.ToString().c_str());
thread->stats.AddNumCompactFilesFailed(1);
} else {
thread->stats.AddNumCompactFilesSucceed(1);
@ -1966,6 +1970,15 @@ class StressTest {
auto column_family = column_families_[rand_column_family];
if (FLAGS_flush_one_in > 0 &&
thread->rand.Uniform(FLAGS_flush_one_in) == 0) {
FlushOptions flush_opts;
Status status = db_->Flush(flush_opts, column_family);
if (!status.ok()) {
fprintf(stdout, "Unable to perform Flush(): %s\n", status.ToString().c_str());
}
}
if (FLAGS_compact_range_one_in > 0 &&
thread->rand.Uniform(FLAGS_compact_range_one_in) == 0) {
int64_t end_key_num;