From 9d3e5a715bf604aa9cf769b726fdc6037d6f1c43 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 22 Nov 2016 18:49:47 +0200 Subject: [PATCH] Cache: Remove item if putting fails If an item cannot be put to the database, it is explicitly removed to ensure that we cannot have the situation that a stale item is continuously returned because the updating of the value fails for whatever reason. --- server/modules/filter/cache/cache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/modules/filter/cache/cache.c b/server/modules/filter/cache/cache.c index 0a5da258b..69d518944 100644 --- a/server/modules/filter/cache/cache.c +++ b/server/modules/filter/cache/cache.c @@ -1256,7 +1256,14 @@ static void store_result(CACHE_SESSION_DATA *csdata) if (result != CACHE_RESULT_OK) { - MXS_ERROR("Could not store cache item."); + MXS_ERROR("Could not store cache item, deleting it."); + + result = csdata->api->delValue(csdata->storage, csdata->key); + + if ((result != CACHE_RESULT_OK) || (result != CACHE_RESULT_NOT_FOUND)) + { + MXS_ERROR("Could not delete cache item."); + } } }