Skip to content

Commit

Permalink
Set options.num_levels in db_stress_test_base (#10732)
Browse files Browse the repository at this point in the history
Summary:
An add-on to #6818 to complete adding single-level universal compaction to stress/crash testing.

Pull Request resolved: #10732

Test Plan:
- Locally run for 10 min `python3 ./tools/db_crashtest.py whitebox --simple --compaction_style=1 --num_levels=1  -max_key=1000000 -value_size_mult=33 -write_buffer_size=524288 -target_file_size_base=524288 -max_bytes_for_level_base=2097152 --duration=120 --interval=10 --ops_per_thread=1000 --random_kill_odd=887`
   - Check LOG to confirm single-level universal compaction is called
- Manual testing and log checking to ensure destroy_db_initially=1 is correctly set across runs with different compaction styles (i.e, in the second half of whitebox testing).
- [ongoing]CI jobs stress test

Reviewed By: ajkr

Differential Revision: D39797612

Pulled By: ajkr

fbshipit-source-id: 16f5c40c3464c57360c06c8305f92118e426149c
  • Loading branch information
Hui Xiao authored and facebook-github-bot committed Sep 27, 2022
1 parent 7045b74 commit f3b359a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,7 @@ void InitializeOptionsFromFlags(
static_cast<ROCKSDB_NAMESPACE::CompactionStyle>(FLAGS_compaction_style);
options.compaction_pri =
static_cast<ROCKSDB_NAMESPACE::CompactionPri>(FLAGS_compaction_pri);
options.num_levels = FLAGS_num_levels;
if (FLAGS_prefix_size >= 0) {
options.prefix_extractor.reset(NewFixedPrefixTransform(FLAGS_prefix_size));
}
Expand Down
8 changes: 7 additions & 1 deletion tools/db_crashtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def whitebox_crash_main(args, unknown_args):
check_mode = 0
kill_random_test = cmd_params["random_kill_odd"]
kill_mode = 0

prev_compaction_style = -1
while time.time() < exit_time:
if check_mode == 0:
additional_opts = {
Expand Down Expand Up @@ -833,6 +833,12 @@ def whitebox_crash_main(args, unknown_args):
"ops_per_thread": cmd_params["ops_per_thread"],
}

cur_compaction_style = additional_opts.get("compaction_style", cmd_params.get("compaction_style", 0))
if prev_compaction_style != -1 and prev_compaction_style != cur_compaction_style:
print("`compaction_style` is changed in current run so `destroy_db_initially` is set to 1 as a short-term solution to avoid cycling through previous db of different compaction style." + "\n")
additional_opts["destroy_db_initially"] = 1
prev_compaction_style = cur_compaction_style

cmd = gen_cmd(
dict(
list(cmd_params.items())
Expand Down

0 comments on commit f3b359a

Please sign in to comment.