From ef26d68e8d027042344a093952b1fa599ac2ac30 Mon Sep 17 00:00:00 2001 From: Hui Xiao Date: Thu, 11 Apr 2024 14:53:11 -0700 Subject: [PATCH] Renable kAdmPolicyThreeQueue in crash test (#12524) Summary: Context/Summary: We need a `nvm_sec_cache` when `kAdmPolicyThreeQueue` is used otherwise a nullptr cache will be accessed causing us segfault in https://github.com/facebook/rocksdb/pull/12521 Pull Request resolved: https://github.com/facebook/rocksdb/pull/12524 Test Plan: - Re-enabled `kAdmPolicyThreeQueue` and rehearsed stress test that failed before this fix and pass after Reviewed By: jowlyzhang Differential Revision: D55997093 Pulled By: hx235 fbshipit-source-id: e1c6f1015091b4cff0ce6a3fff981d5dece52a62 --- db_stress_tool/db_stress_test_base.cc | 8 +++++++- tools/db_crashtest.py | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index c426cce161..a503da1543 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -192,7 +192,6 @@ std::shared_ptr StressTest::NewCache(size_t capacity, static_cast(FLAGS_adm_policy); if (tiered_opts.adm_policy == TieredAdmissionPolicy::kAdmPolicyThreeQueue) { - std::shared_ptr nvm_sec_cache; CompressedSecondaryCacheOptions nvm_sec_cache_opts; nvm_sec_cache_opts.capacity = cache_size; tiered_opts.nvm_sec_cache = @@ -220,6 +219,13 @@ std::shared_ptr StressTest::NewCache(size_t capacity, tiered_opts.compressed_secondary_ratio = 0.5; tiered_opts.adm_policy = static_cast(FLAGS_adm_policy); + if (tiered_opts.adm_policy == + TieredAdmissionPolicy::kAdmPolicyThreeQueue) { + CompressedSecondaryCacheOptions nvm_sec_cache_opts; + nvm_sec_cache_opts.capacity = cache_size; + tiered_opts.nvm_sec_cache = + NewCompressedSecondaryCache(nvm_sec_cache_opts); + } block_cache = NewTieredCache(tiered_opts); } else { opts.secondary_cache = std::move(secondary_cache); diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 0ad0a5733f..b11532b7d5 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -273,9 +273,7 @@ default_params = { "block_align": 0, "lowest_used_cache_tier": lambda: random.choice([0, 1, 2]), "enable_custom_split_merge": lambda: random.choice([0, 1]), - # TODO(hx235): enable `kAdmPolicyThreeQueue` after fixing the surfaced segfault - # issue in CompressedCacheSetCapacityThread - "adm_policy": lambda: random.choice([0, 1, 2]), + "adm_policy": lambda: random.choice([0, 1, 2, 3]), "last_level_temperature": lambda: random.choice(["kUnknown", "kHot", "kWarm", "kCold"]), "default_write_temperature": lambda: random.choice(["kUnknown", "kHot", "kWarm", "kCold"]), "default_temperature": lambda: random.choice(["kUnknown", "kHot", "kWarm", "kCold"]),