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.
This commit is contained in:
Johan Wikman 2016-11-22 18:49:47 +02:00
parent e9029b183e
commit 9d3e5a715b

View File

@ -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.");
}
}
}