From 2afea29762a214f099e1e4749b04839646657478 Mon Sep 17 00:00:00 2001 From: anand76 Date: Tue, 17 Dec 2019 20:43:06 -0800 Subject: [PATCH] Add VerifyChecksum() to db_stress (#6203) Summary: Add an option to db_stress, verify_checksum_one_in, to call DB::VerifyChecksum() once every N ops. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6203 Differential Revision: D19145753 Pulled By: anand1976 fbshipit-source-id: d09edf21f309ad53aa40dd25b7a563d50665fd8b --- db_stress_tool/db_stress_common.h | 1 + db_stress_tool/db_stress_gflags.cc | 5 +++++ db_stress_tool/db_stress_test_base.cc | 9 +++++++++ tools/db_crashtest.py | 2 ++ 4 files changed, 17 insertions(+) diff --git a/db_stress_tool/db_stress_common.h b/db_stress_tool/db_stress_common.h index 77841365b..ade10a426 100644 --- a/db_stress_tool/db_stress_common.h +++ b/db_stress_tool/db_stress_common.h @@ -207,6 +207,7 @@ DECLARE_bool(avoid_unnecessary_blocking_io); DECLARE_bool(write_dbid_to_manifest); DECLARE_uint64(max_write_batch_group_size_bytes); DECLARE_bool(level_compaction_dynamic_level_bytes); +DECLARE_int32(verify_checksum_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 bc9395866..a66fbbf31 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -577,4 +577,9 @@ DEFINE_bool(level_compaction_dynamic_level_bytes, rocksdb::Options().level_compaction_dynamic_level_bytes, "Use dynamic level"); +DEFINE_int32(verify_checksum_one_in, 0, + "If non-zero, then DB::VerifyChecksum() will be called to do" + " checksum verification of all the files in the database once for" + " every N ops on average. 0 indicates that calls to" + " VerifyChecksum() 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 8d46e0ea8..e7b6cccc7 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -625,6 +625,15 @@ void StressTest::OperateDb(ThreadState* thread) { } } +#ifndef ROCKSDB_LITE + if (thread->rand.OneInOpt(FLAGS_verify_checksum_one_in)) { + Status status = db_->VerifyChecksum(); + if (!status.ok()) { + VerificationAbort(shared, "VerifyChecksum status not OK", status); + } + } +#endif + std::vector rand_keys = GenerateKeys(rand_key); if (thread->rand.OneInOpt(FLAGS_ingest_external_file_one_in)) { diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index dfef17660..003688e04 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -97,6 +97,8 @@ default_params = { "max_write_batch_group_size_bytes" : lambda: random.choice( [16, 64, 1024 * 1024, 16 * 1024 * 1024]), "level_compaction_dynamic_level_bytes" : True, + [t * 16384 if t < 3 else 1024 * 1024 * 1024 for t in range(1,30)]), + "verify_checksum_one_in": 1000000 } _TEST_DIR_ENV_VAR = 'TEST_TMPDIR'