diff --git a/db_stress_tool/db_stress_common.h b/db_stress_tool/db_stress_common.h index bdc82618b8..41f67728d9 100644 --- a/db_stress_tool/db_stress_common.h +++ b/db_stress_tool/db_stress_common.h @@ -102,6 +102,7 @@ DECLARE_bool(destroy_db_initially); DECLARE_bool(verbose); DECLARE_bool(progress_reports); DECLARE_uint64(db_write_buffer_size); +DECLARE_bool(allow_wbm_stalls); DECLARE_int32(write_buffer_size); DECLARE_int32(max_write_buffer_number); DECLARE_int32(min_write_buffer_number_to_merge); diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index d615ed234f..78c8da1eb4 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -135,6 +135,8 @@ DEFINE_uint64(db_write_buffer_size, ROCKSDB_NAMESPACE::Options().db_write_buffer_size, "Number of bytes to buffer in all memtables before compacting"); +DEFINE_bool(allow_wbm_stalls, false, "Enable WBM write stalls and delays"); + DEFINE_int32( write_buffer_size, static_cast(ROCKSDB_NAMESPACE::Options().write_buffer_size), diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 2d3b63e7d6..bc9f424a95 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -3178,7 +3178,10 @@ void InitializeOptionsFromFlags( block_based_options.num_file_reads_for_auto_readahead = FLAGS_num_file_reads_for_auto_readahead; options.table_factory.reset(NewBlockBasedTableFactory(block_based_options)); - options.db_write_buffer_size = FLAGS_db_write_buffer_size; + if (FLAGS_db_write_buffer_size > 0) { + options.write_buffer_manager.reset(new WriteBufferManager( + FLAGS_db_write_buffer_size, {} /* cache */, FLAGS_allow_wbm_stalls)); + } options.write_buffer_size = FLAGS_write_buffer_size; options.max_write_buffer_number = FLAGS_max_write_buffer_number; options.min_write_buffer_number_to_merge = diff --git a/db_stress_tool/db_stress_tool.cc b/db_stress_tool/db_stress_tool.cc index 8cbbde52f9..c52a59972d 100644 --- a/db_stress_tool/db_stress_tool.cc +++ b/db_stress_tool/db_stress_tool.cc @@ -367,6 +367,13 @@ int db_stress_tool(int argc, char** argv) { keys_per_level * (levels - 1)); } std::unique_ptr shared; + + if ((FLAGS_db_write_buffer_size == 0) && FLAGS_allow_wbm_stalls) { + fprintf(stderr, + "-allow_wbm_stalls is useless if db_write_buffer_size == 0\n"); + exit(1); + } + std::unique_ptr stress; if (FLAGS_test_cf_consistency) { stress.reset(CreateCfConsistencyStressTest());