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
This commit is contained in:
Hui Xiao 2024-04-11 14:53:11 -07:00 committed by Facebook GitHub Bot
parent 85925051c7
commit ef26d68e8d
2 changed files with 8 additions and 4 deletions

View File

@ -192,7 +192,6 @@ std::shared_ptr<Cache> StressTest::NewCache(size_t capacity,
static_cast<TieredAdmissionPolicy>(FLAGS_adm_policy); static_cast<TieredAdmissionPolicy>(FLAGS_adm_policy);
if (tiered_opts.adm_policy == if (tiered_opts.adm_policy ==
TieredAdmissionPolicy::kAdmPolicyThreeQueue) { TieredAdmissionPolicy::kAdmPolicyThreeQueue) {
std::shared_ptr<SecondaryCache> nvm_sec_cache;
CompressedSecondaryCacheOptions nvm_sec_cache_opts; CompressedSecondaryCacheOptions nvm_sec_cache_opts;
nvm_sec_cache_opts.capacity = cache_size; nvm_sec_cache_opts.capacity = cache_size;
tiered_opts.nvm_sec_cache = tiered_opts.nvm_sec_cache =
@ -220,6 +219,13 @@ std::shared_ptr<Cache> StressTest::NewCache(size_t capacity,
tiered_opts.compressed_secondary_ratio = 0.5; tiered_opts.compressed_secondary_ratio = 0.5;
tiered_opts.adm_policy = tiered_opts.adm_policy =
static_cast<TieredAdmissionPolicy>(FLAGS_adm_policy); static_cast<TieredAdmissionPolicy>(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); block_cache = NewTieredCache(tiered_opts);
} else { } else {
opts.secondary_cache = std::move(secondary_cache); opts.secondary_cache = std::move(secondary_cache);

View File

@ -273,9 +273,7 @@ default_params = {
"block_align": 0, "block_align": 0,
"lowest_used_cache_tier": lambda: random.choice([0, 1, 2]), "lowest_used_cache_tier": lambda: random.choice([0, 1, 2]),
"enable_custom_split_merge": lambda: random.choice([0, 1]), "enable_custom_split_merge": lambda: random.choice([0, 1]),
# TODO(hx235): enable `kAdmPolicyThreeQueue` after fixing the surfaced segfault "adm_policy": lambda: random.choice([0, 1, 2, 3]),
# issue in CompressedCacheSetCapacityThread
"adm_policy": lambda: random.choice([0, 1, 2]),
"last_level_temperature": lambda: random.choice(["kUnknown", "kHot", "kWarm", "kCold"]), "last_level_temperature": lambda: random.choice(["kUnknown", "kHot", "kWarm", "kCold"]),
"default_write_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"]), "default_temperature": lambda: random.choice(["kUnknown", "kHot", "kWarm", "kCold"]),