diff options
author | sdong <siying.d@fb.com> | 2015-10-14 14:08:50 -0700 |
---|---|---|
committer | sdong <siying.d@fb.com> | 2015-10-15 14:33:13 -0700 |
commit | e1a5ff857b7fdeafe049e6859f028c502c2f4799 (patch) | |
tree | 22998be57635dab351faeba496e607da59f03f3d /tools | |
parent | d306a7ea85144f9d420825ff5dc72693ff126287 (diff) |
Allow users to disable some kill points in db_stress
Summary:
Give a name for every kill point, and allow users to disable some kill points based on prefixes. The kill points can be passed by db_stress through a command line paramter. This provides a way for users to boost the chance of triggering low frequency kill points
This allow follow up changes in crash test scripts to improve crash test coverage.
Test Plan:
Manually run db_stress with variable values of --kill_random_test and --kill_prefix_blacklist. Like this:
--kill_random_test=2 --kill_prefix_blacklist=Posix,WritableFileWriter::Append,WritableFileWriter::WriteBuffered,WritableFileWriter::Sync
Reviewers: igor, kradhakrishnan, rven, IslamAbdelRahman, yhchiang
Reviewed By: yhchiang
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D48735
Diffstat (limited to 'tools')
-rw-r--r-- | tools/db_stress.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 634045dfb..1b1672ca2 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -277,6 +277,11 @@ static const bool FLAGS_kill_random_test_dummy __attribute__((unused)) = RegisterFlagValidator(&FLAGS_kill_random_test, &ValidateInt32Positive); extern int rocksdb_kill_odds; +DEFINE_string(kill_prefix_blacklist, "", + "If non-empty, kill points with prefix in the list given will be" + " skipped. Items are comma-separated."); +extern std::vector<std::string> rocksdb_kill_prefix_blacklist; + DEFINE_bool(disable_wal, false, "If true, do not write WAL for write."); DEFINE_int32(target_file_size_base, 64 * KB, @@ -356,6 +361,21 @@ enum rocksdb::CompressionType StringToCompressionType(const char* ctype) { fprintf(stdout, "Cannot parse compression type '%s'\n", ctype); return rocksdb::kSnappyCompression; //default value } + +std::vector<std::string> SplitString(std::string src) { + std::vector<std::string> ret; + if (src.empty()) { + return ret; + } + size_t pos = 0; + size_t pos_comma; + while ((pos_comma = src.find(',', pos)) != std::string::npos) { + ret.push_back(src.substr(pos, pos_comma - pos)); + pos = pos_comma + 1; + } + ret.push_back(src.substr(pos, src.length())); + return ret; +} } // namespace DEFINE_string(compression_type, "snappy", @@ -1921,6 +1941,14 @@ class StressTest { fprintf(stdout, "Memtablerep : %s\n", memtablerep); + fprintf(stdout, "Test kill odd : %d\n", rocksdb_kill_odds); + if (!rocksdb_kill_prefix_blacklist.empty()) { + fprintf(stdout, "Skipping kill points prefixes:\n"); + for (auto& p : rocksdb_kill_prefix_blacklist) { + fprintf(stdout, " %s\n", p.c_str()); + } + } + fprintf(stdout, "------------------------------------------------\n"); } @@ -1952,7 +1980,6 @@ class StressTest { options_.disableDataSync = FLAGS_disable_data_sync; options_.use_fsync = FLAGS_use_fsync; options_.allow_mmap_reads = FLAGS_mmap_read; - rocksdb_kill_odds = FLAGS_kill_random_test; 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; @@ -2186,6 +2213,9 @@ int main(int argc, char** argv) { FLAGS_db = default_db_path; } + rocksdb_kill_odds = FLAGS_kill_random_test; + rocksdb_kill_prefix_blacklist = SplitString(FLAGS_kill_prefix_blacklist); + rocksdb::StressTest stress; if (stress.Run()) { return 0; |