From dcdd7435bdf63a4e1ec5f9b3fd508c6a8def4a34 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Sun, 27 Jan 2019 14:44:20 +0200 Subject: [PATCH] Added sync-wait option to dbsim. --- dbsim/db_client.cpp | 7 +++++++ dbsim/db_params.cpp | 6 ++++-- dbsim/db_params.hpp | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dbsim/db_client.cpp b/dbsim/db_client.cpp index dc3f923..26d8b87 100644 --- a/dbsim/db_client.cpp +++ b/dbsim/db_client.cpp @@ -90,6 +90,13 @@ int db::client::client_command(F f) void db::client::run_one_transaction() { + if (params_.sync_wait) + { + if (client_state_.sync_wait(5)) + { + throw wsrep::runtime_error("Sync wait failed"); + } + } client_state_.reset_error(); int err = client_command( [&]() diff --git a/dbsim/db_params.cpp b/dbsim/db_params.cpp index 92bc229..ac8b1a8 100644 --- a/dbsim/db_params.cpp +++ b/dbsim/db_params.cpp @@ -69,6 +69,8 @@ db::params db::parse_args(int argc, char** argv) "number of rows per table") ("alg-freq", po::value(¶ms.alg_freq), "ALG frequency") + ("sync-wait", po::value(¶ms.sync_wait), + "Turn on sync wait for each transaction") ("debug-log-level", po::value(¶ms.debug_log_level), "debug logging level: 0 - none, 1 - verbose") ("fast-exit", po::value(¶ms.fast_exit), @@ -86,18 +88,18 @@ db::params db::parse_args(int argc, char** argv) { po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); if (vm.count("help")) { std::cerr << desc << "\n"; exit(0); } - + po::notify(vm); validate_params(params); } catch (const po::error& e) { std::cerr << "Error parsing arguments: " << e.what() << "\n"; + std::cerr << desc << "\n"; exit(1); } catch (...) diff --git a/dbsim/db_params.hpp b/dbsim/db_params.hpp index 10bf0b7..57e279e 100644 --- a/dbsim/db_params.hpp +++ b/dbsim/db_params.hpp @@ -32,6 +32,7 @@ namespace db size_t n_transactions; size_t n_rows; size_t alg_freq; + bool sync_wait; std::string topology; std::string wsrep_provider; std::string wsrep_provider_options; @@ -45,6 +46,7 @@ namespace db , n_transactions(0) , n_rows(1000) , alg_freq(0) + , sync_wait(false) , topology() , wsrep_provider() , wsrep_provider_options()