From ac1049b8cd3d90ee7ecdab965538741c878159f6 Mon Sep 17 00:00:00 2001 From: anand76 Date: Tue, 21 Feb 2023 11:04:25 -0800 Subject: [PATCH 1/2] Revert enabling IO uring in db_stress Summary: Revert the change to enable IO uring in db_stress, and also re-enable async_io in CircleCI so that code path can be tested. Added the -use_io_uring flag to db_stress that, when false, will wrap the default env in db_stress to emulate async IO. Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .circleci/config.yml | 6 +++--- db_stress_tool/db_stress_common.h | 1 + db_stress_tool/db_stress_gflags.cc | 4 +++- db_stress_tool/db_stress_tool.cc | 7 +++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ddb651b4fb..c614d3f0e22 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -516,7 +516,7 @@ jobs: resource_class: large steps: - pre-steps - - run: ulimit -S -n `ulimit -H -n` && make V=1 -j8 CRASH_TEST_EXT_ARGS='--duration=960 --max_key=2500000 --async_io=0' blackbox_crash_test_with_atomic_flush + - run: ulimit -S -n `ulimit -H -n` && make V=1 -j8 CRASH_TEST_EXT_ARGS='--duration=960 --max_key=2500000 --use_io_uring=0' blackbox_crash_test_with_atomic_flush - post-steps build-linux-crashtest-tiered-storage-bb: @@ -526,7 +526,7 @@ jobs: - pre-steps - run: name: "run crashtest" - command: ulimit -S -n `ulimit -H -n` && make V=1 -j32 CRASH_TEST_EXT_ARGS='--duration=10800 --async_io=0' blackbox_crash_test_with_tiered_storage + command: ulimit -S -n `ulimit -H -n` && make V=1 -j32 CRASH_TEST_EXT_ARGS='--duration=10800 --use_io_uring=0' blackbox_crash_test_with_tiered_storage no_output_timeout: 100m - post-steps @@ -537,7 +537,7 @@ jobs: - pre-steps - run: name: "run crashtest" - command: ulimit -S -n `ulimit -H -n` && make V=1 -j32 CRASH_TEST_EXT_ARGS='--duration=10800 --async_io=0' whitebox_crash_test_with_tiered_storage + command: ulimit -S -n `ulimit -H -n` && make V=1 -j32 CRASH_TEST_EXT_ARGS='--duration=10800 --use_io_uring=0' whitebox_crash_test_with_tiered_storage no_output_timeout: 100m - post-steps diff --git a/db_stress_tool/db_stress_common.h b/db_stress_tool/db_stress_common.h index 1256cc146bf..e029216bb95 100644 --- a/db_stress_tool/db_stress_common.h +++ b/db_stress_tool/db_stress_common.h @@ -321,6 +321,7 @@ DECLARE_uint64(readahead_size); DECLARE_uint64(initial_auto_readahead_size); DECLARE_uint64(max_auto_readahead_size); DECLARE_uint64(num_file_reads_for_auto_readahead); +DECLARE_bool(use_io_uring); constexpr long KB = 1024; constexpr int kRandomValueMaxFactor = 3; diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index 4043c7b5442..564e4fe149f 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -1073,6 +1073,8 @@ DEFINE_uint64(stats_dump_period_sec, ROCKSDB_NAMESPACE::Options().stats_dump_period_sec, "Gap between printing stats to log in seconds"); -extern "C" bool RocksDbIOUringEnable() { return true; } +DEFINE_bool(use_io_uring, false, + "Enable the use of IO uring on Posix"); +extern "C" bool RocksDbIOUringEnable() { return FLAGS_use_io_uring; } #endif // GFLAGS diff --git a/db_stress_tool/db_stress_tool.cc b/db_stress_tool/db_stress_tool.cc index c41c5051f39..c37117921cc 100644 --- a/db_stress_tool/db_stress_tool.cc +++ b/db_stress_tool/db_stress_tool.cc @@ -99,6 +99,13 @@ int db_stress_tool(int argc, char** argv) { env_wrapper_guard = std::make_shared( raw_env, std::make_shared(raw_env->GetFileSystem())); + if (!env_opts && !FLAGS_use_io_uring) { + // If using the default Env (Posix), wrap DbStressEnvWrapper with the + // legacy EnvWrapper. This is a workaround to prevent MultiGet and scans + // from failing when IO uring is disabled. The EnvWrapper + // has a default implementation of ReadAsync that redirects to Read. + env_wrapper_guard = std::make_shared(env_wrapper_guard); + } db_stress_env = env_wrapper_guard.get(); FLAGS_rep_factory = StringToRepFactory(FLAGS_memtablerep.c_str()); From c9402fa8053872c13e06d236d93753042b70acd4 Mon Sep 17 00:00:00 2001 From: anand76 Date: Tue, 21 Feb 2023 11:09:08 -0800 Subject: [PATCH 2/2] Fix formatting --- db_stress_tool/db_stress_gflags.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index 564e4fe149f..8b7354bf2e7 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -1073,8 +1073,7 @@ DEFINE_uint64(stats_dump_period_sec, ROCKSDB_NAMESPACE::Options().stats_dump_period_sec, "Gap between printing stats to log in seconds"); -DEFINE_bool(use_io_uring, false, - "Enable the use of IO uring on Posix"); +DEFINE_bool(use_io_uring, false, "Enable the use of IO uring on Posix"); extern "C" bool RocksDbIOUringEnable() { return FLAGS_use_io_uring; } #endif // GFLAGS