Skip to content

Commit

Permalink
Support manual flush in stress/crash tests (#4368)
Browse files Browse the repository at this point in the history
Summary:
- Made stress test call `Flush()` periodically according to `--flush_one_in` flag.
- Enabled by default in crash test.
Pull Request resolved: #4368

Differential Revision: D9838593

Pulled By: ajkr

fbshipit-source-id: fe5a6e49b36e5ea752acc3aa8be364f8ef34d9cc
  • Loading branch information
ajkr authored and facebook-github-bot committed Sep 17, 2018
1 parent ac46790 commit 8c25204
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions tools/db_crashtest.py
Expand Up @@ -32,6 +32,7 @@
"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,
Expand Down
17 changes: 15 additions & 2 deletions tools/db_stress.cc
Expand Up @@ -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().");

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 8c25204

Please sign in to comment.