From f3b359a5497f4d81061e3e412ca7706dea26b5fd Mon Sep 17 00:00:00 2001 From: Hui Xiao Date: Tue, 27 Sep 2022 12:18:28 -0700 Subject: [PATCH] Set options.num_levels in db_stress_test_base (#10732) Summary: An add-on to https://github.com/facebook/rocksdb/pull/6818 to complete adding single-level universal compaction to stress/crash testing. Pull Request resolved: https://github.com/facebook/rocksdb/pull/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 --- db_stress_tool/db_stress_test_base.cc | 1 + tools/db_crashtest.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index f8fd1e5dc..f04bc672a 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -3028,6 +3028,7 @@ void InitializeOptionsFromFlags( static_cast(FLAGS_compaction_style); options.compaction_pri = static_cast(FLAGS_compaction_pri); + options.num_levels = FLAGS_num_levels; if (FLAGS_prefix_size >= 0) { options.prefix_extractor.reset(NewFixedPrefixTransform(FLAGS_prefix_size)); } diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 048fffc81..bc17a0115 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -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 = { @@ -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())