From 383f5071f0fa85af5f26b13224b2809d0896a8ff Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Tue, 10 Dec 2019 21:53:43 -0800 Subject: [PATCH] Add SyncWAL to db_stress (#6149) Summary: Add SyncWAL to db_stress. Specify with `-sync_wal_one_in=N` so that it will be called once every N operations on average. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6149 Test Plan: ``` $make db_stress $./db_stress -sync_wal_one_in=100 -ops_per_thread=100000 ``` Differential Revision: D18922529 Pulled By: riversand963 fbshipit-source-id: 4c0b8cb8fa21852722cffd957deddf688f12ea56 --- db_stress_tool/db_stress_common.h | 1 + db_stress_tool/db_stress_gflags.cc | 4 ++++ db_stress_tool/db_stress_test_base.cc | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/db_stress_tool/db_stress_common.h b/db_stress_tool/db_stress_common.h index 8bb9667de..b66cce6df 100644 --- a/db_stress_tool/db_stress_common.h +++ b/db_stress_tool/db_stress_common.h @@ -197,6 +197,7 @@ DECLARE_string(memtablerep); DECLARE_int32(prefix_size); DECLARE_bool(use_merge); DECLARE_bool(use_full_merge_v1); +DECLARE_int32(sync_wal_one_in); const long KB = 1024; const int kRandomValueMaxFactor = 3; diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index a4198be6b..328426fb1 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -533,4 +533,8 @@ DEFINE_bool(use_merge, false, DEFINE_bool(use_full_merge_v1, false, "On true, use a merge operator that implement the deprecated " "version of FullMerge"); + +DEFINE_int32(sync_wal_one_in, 0, + "If non-zero, then SyncWAL() will be called once for every N ops " + "on average. 0 indicates that calls to SyncWAL() are disabled."); #endif // GFLAGS diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index cf6346efb..07f3df74a 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -513,6 +513,14 @@ void StressTest::OperateDb(ThreadState* thread) { MaybeClearOneColumnFamily(thread); + if (FLAGS_sync_wal_one_in > 0 && + thread->rand.Uniform(FLAGS_sync_wal_one_in) == 0) { + Status s = db_->SyncWAL(); + if (!s.ok() && !s.IsNotSupported()) { + fprintf(stdout, "SyncWAL() failed: %s\n", s.ToString().c_str()); + } + } + #ifndef ROCKSDB_LITE if (FLAGS_compact_files_one_in > 0 && thread->rand.Uniform(FLAGS_compact_files_one_in) == 0) { -- GitLab