From e179629fc811e2a6de4a210a5d03a00e3e107585 Mon Sep 17 00:00:00 2001 From: chejinge Date: Wed, 24 Sep 2025 17:21:52 +0800 Subject: [PATCH 1/2] fix:block_cache_size --- src/pika_server.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/pika_server.cc b/src/pika_server.cc index b205f3e34b..2af7e6e7eb 100644 --- a/src/pika_server.cc +++ b/src/pika_server.cc @@ -1479,12 +1479,21 @@ void PikaServer::InitStorageOptions() { storage_options_.table_options.pin_l0_filter_and_index_blocks_in_cache = g_pika_conf->pin_l0_filter_and_index_blocks_in_cache(); - if (storage_options_.block_cache_size == 0) { - storage_options_.table_options.no_block_cache = true; - } else if (storage_options_.share_block_cache) { - storage_options_.table_options.block_cache = - rocksdb::NewLRUCache(storage_options_.block_cache_size, static_cast(g_pika_conf->num_shard_bits())); - } + if (storage_options_.block_cache_size == 0) { + storage_options_.table_options.no_block_cache = true; + storage_options_.table_options.block_cache.reset(); + } else if (storage_options_.share_block_cache) { + // 共享模式:直接复用已创建好的全局 cache(PikaServer 成员) + storage_options_.table_options.no_block_cache = false; + assert(share_block_cache_ && "shared_block_cache_ must be initialized before InitStorageOptions()"); + storage_options_.table_options.block_cache = shared_block_cache_; + } else { + // 非共享模式:为当前 CF/实例单独创建 + storage_options_.table_options.no_block_cache = false; + storage_options_.table_options.block_cache = + rocksdb::NewLRUCache(storage_options_.block_cache_size, + static_cast(g_pika_conf->num_shard_bits())); + } storage_options_.options.rate_limiter = std::shared_ptr( rocksdb::NewGenericRateLimiter( From 878e9183b90bca39812a19d857b699f010a72874 Mon Sep 17 00:00:00 2001 From: chejinge Date: Thu, 25 Sep 2025 20:17:55 +0800 Subject: [PATCH 2/2] fix:block_cache_size --- src/pika_server.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pika_server.cc b/src/pika_server.cc index 2af7e6e7eb..86b2171f93 100644 --- a/src/pika_server.cc +++ b/src/pika_server.cc @@ -1478,17 +1478,19 @@ void PikaServer::InitStorageOptions() { storage_options_.table_options.pin_l0_filter_and_index_blocks_in_cache = g_pika_conf->pin_l0_filter_and_index_blocks_in_cache(); - if (storage_options_.block_cache_size == 0) { + // 禁用 block_cache storage_options_.table_options.no_block_cache = true; storage_options_.table_options.block_cache.reset(); } else if (storage_options_.share_block_cache) { - // 共享模式:直接复用已创建好的全局 cache(PikaServer 成员) + if (!g_pika_conf->share_block_cache()) { + assert(false && "shared_block_cache_ must be initialized before InitStorageOptions()"); + } + storage_options_.table_options.no_block_cache = false; - assert(share_block_cache_ && "shared_block_cache_ must be initialized before InitStorageOptions()"); - storage_options_.table_options.block_cache = shared_block_cache_; + + storage_options_.table_options.block_cache = 0; } else { - // 非共享模式:为当前 CF/实例单独创建 storage_options_.table_options.no_block_cache = false; storage_options_.table_options.block_cache = rocksdb::NewLRUCache(storage_options_.block_cache_size,