From 2263f86901313da2d6e1c940d164291094df4abb Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Fri, 15 Mar 2019 11:58:37 -0700 Subject: [PATCH] exercise WAL recycling in crash test (#5070) Summary: Since this feature affects the WAL behavior, it seems important our crash-recovery tests cover it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5070 Differential Revision: D14470085 Pulled By: miasantreble fbshipit-source-id: 9b9682a718a926d57d055e0a5ec867efbd2eb9c1 --- tools/db_crashtest.py | 1 + tools/db_stress.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index cd53fefce4..dbabb2b4f8 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -48,6 +48,7 @@ default_params = { "prefixpercent": 5, "progress_reports": 0, "readpercent": 45, + "recycle_log_file_num": lambda: random.randint(0, 1), "reopen": 20, "snapshot_hold_ops": 100000, "subcompactions": lambda: random.randint(1, 4), diff --git a/tools/db_stress.cc b/tools/db_stress.cc index b916bf5fff..1d079a7c7f 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -379,6 +379,9 @@ extern std::vector rocksdb_kill_prefix_blacklist; DEFINE_bool(disable_wal, false, "If true, do not write WAL for write."); +DEFINE_uint64(recycle_log_file_num, rocksdb::Options().recycle_log_file_num, + "Number of old WAL files to keep around for later recycling"); + DEFINE_int64(target_file_size_base, rocksdb::Options().target_file_size_base, "Target level-1 file size for compaction"); @@ -2605,6 +2608,8 @@ class StressTest { options_.use_direct_reads = FLAGS_use_direct_reads; options_.use_direct_io_for_flush_and_compaction = FLAGS_use_direct_io_for_flush_and_compaction; + options_.recycle_log_file_num = + static_cast(FLAGS_recycle_log_file_num); options_.target_file_size_base = FLAGS_target_file_size_base; options_.target_file_size_multiplier = FLAGS_target_file_size_multiplier; options_.max_bytes_for_level_base = FLAGS_max_bytes_for_level_base;