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
main
Yanqin Jin 5 years ago committed by Facebook Github Bot
parent 7a99162a74
commit 383f5071f0
  1. 1
      db_stress_tool/db_stress_common.h
  2. 4
      db_stress_tool/db_stress_gflags.cc
  3. 8
      db_stress_tool/db_stress_test_base.cc

@ -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;

@ -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

@ -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) {

Loading…
Cancel
Save