From d7aea6955ca06656d401ac177bfb2dfd1eaacd93 Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Fri, 21 Feb 2025 10:50:01 -0800 Subject: [PATCH] Fix stress test DB verification methods (#13409) Summary: update VerifyDB() to respect user specified flags when choosing verification method. Pull Request resolved: https://github.com/facebook/rocksdb/pull/13409 Test Plan: existing CI. Reviewed By: hx235 Differential Revision: D69885644 Pulled By: cbi42 fbshipit-source-id: bbaa931cece3525f00d775639ec7b63ff0101d94 --- db_stress_tool/db_stress_gflags.cc | 8 +++++--- db_stress_tool/no_batched_ops_stress.cc | 13 ++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index d32d86199a..94028f07b4 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -831,13 +831,15 @@ DEFINE_uint64(snapshot_hold_ops, 0, DEFINE_bool(long_running_snapshots, false, "If set, hold on some some snapshots for much longer time."); +// The following three options affect both regular read operations during the +// test and initial/final database verification through VerifyDB. DEFINE_bool(use_multiget, false, - "If set, use the batched MultiGet API for reads"); + "If set, use the batched MultiGet API for reads."); -DEFINE_bool(use_get_entity, false, "If set, use the GetEntity API for reads"); +DEFINE_bool(use_get_entity, false, "If set, use the GetEntity API for reads."); DEFINE_bool(use_multi_get_entity, false, - "If set, use the MultiGetEntity API for reads"); + "If set, use the MultiGetEntity API for reads."); DEFINE_int32(test_ingest_standalone_range_deletion_one_in, 0, "If non-zero, file ingestion flow will test standalone range " diff --git a/db_stress_tool/no_batched_ops_stress.cc b/db_stress_tool/no_batched_ops_stress.cc index 0b68fb55b1..616035a1b4 100644 --- a/db_stress_tool/no_batched_ops_stress.cc +++ b/db_stress_tool/no_batched_ops_stress.cc @@ -72,10 +72,21 @@ class NonBatchedOpsStressTest : public StressTest { constexpr int num_methods = static_cast(VerificationMethod::kNumberOfMethods); - const VerificationMethod method = + VerificationMethod method = static_cast(thread->rand.Uniform( (FLAGS_user_timestamp_size > 0) ? num_methods - 1 : num_methods)); + if (method == VerificationMethod::kGetEntity && !FLAGS_use_get_entity) { + method = VerificationMethod::kGet; + } + if (method == VerificationMethod::kMultiGetEntity && + !FLAGS_use_multi_get_entity) { + method = VerificationMethod::kMultiGet; + } + if (method == VerificationMethod::kMultiGet && !FLAGS_use_multiget) { + method = VerificationMethod::kGet; + } + if (method == VerificationMethod::kIterator) { std::unique_ptr snapshot = nullptr; if (options.auto_refresh_iterator_with_snapshot) {