From 9a87ae46fd9b5db3e156c8e8680b25d524a58352 Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Tue, 17 Sep 2019 00:14:29 -0700 Subject: [PATCH] Use total charge in MaintainPoolSize (#5813) Summary: https://github.com/facebook/rocksdb/issues/5797 charges the block cache with the total of user-provided charge plus the metadata charge. It had a bug where in MaintainPoolSize the user-provided charge was used instead of the total charge. The patch fixes that. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5813 Differential Revision: D17412783 Pulled By: maysamyabandeh fbshipit-source-id: 45c0ac9f1e2233760db5ccd61399605cd74edc87 --- cache/lru_cache.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cache/lru_cache.cc b/cache/lru_cache.cc index 85d2d67ec..0e49167ed 100644 --- a/cache/lru_cache.cc +++ b/cache/lru_cache.cc @@ -225,8 +225,10 @@ void LRUCacheShard::MaintainPoolSize() { lru_low_pri_ = lru_low_pri_->next; assert(lru_low_pri_ != &lru_); lru_low_pri_->SetInHighPriPool(false); - assert(high_pri_pool_usage_ >= lru_low_pri_->charge); - high_pri_pool_usage_ -= lru_low_pri_->charge; + size_t total_charge = + lru_low_pri_->CalcTotalCharge(metadata_charge_policy_); + assert(high_pri_pool_usage_ >= total_charge); + high_pri_pool_usage_ -= total_charge; } }