From 1c28eefbd0d964d6d29a9ad2a7fd5f48362ac7e6 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 12 Nov 2019 15:27:31 +0200 Subject: [PATCH] MXS-2727 Add fix If an existing cache-entry should be updated, but the new value is larger that the maximum size of the cache, then the cache can not be updated, but the old value must be removed. Whether or not we succeed in removing the entry, an error result must be returned. Earlier OK was returned, but no node was allocated, which then caused a crash. --- server/modules/filter/cache/lrustorage.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/modules/filter/cache/lrustorage.cc b/server/modules/filter/cache/lrustorage.cc index 2272771a1..ec43ee3c5 100644 --- a/server/modules/filter/cache/lrustorage.cc +++ b/server/modules/filter/cache/lrustorage.cc @@ -479,11 +479,14 @@ cache_result_t LRUStorage::get_existing_node(NodesByKey::iterator& i, const GWBU result = do_del_value(*pkey); - if (!CACHE_RESULT_IS_ERROR(result)) + if (CACHE_RESULT_IS_ERROR(result)) { - // If we failed to remove the value, we do not have enough space. - result = CACHE_RESULT_OUT_OF_RESOURCES; + // Removal of old value of too big a value to be cached failed, we are hosed. + MXS_ERROR("Value is too big to be stored, and removal of old value " + "failed. The cache will return stale data."); } + + result = CACHE_RESULT_OUT_OF_RESOURCES; } else {