fix for PGC wanted_cache_size getting to zero (#19370)
fix for wanted_cache_size getting to zero
Costa Tsaousis committed
Jan 10, 2025 at 13:47 UTC
09f043b9876a34205b46ec2de015ab93f81d8b2a
1 file changed
+4
src/database/engine/cache.c
+4
@@ -428,6 +428,10 @@ static inline size_t cache_usage_per1000(PGC *cache, size_t *size_to_evict) {
428
if(unlikely(wanted_cache_size < min_cache_size))
429
wanted_cache_size = min_cache_size;
430
431
+ // protection for the case the cache is totally empty
432
+ if(unlikely(wanted_cache_size < 65536))
433
+ wanted_cache_size = 65536;
434
+
435
const size_t per1000 = (size_t)(current_cache_size * 1000ULL / wanted_cache_size);
436
__atomic_store_n(&cache->usage.per1000, per1000, __ATOMIC_RELAXED);
437
__atomic_store_n(&cache->stats.wanted_cache_size, wanted_cache_size, __ATOMIC_RELAXED);