Add fallback if we fail to evict normally with FLASH (flush everything)

Former-commit-id: 66ee85a8d5e24514083aa3478dcf0cf3da86520e
This commit is contained in:
John Sully 2020-03-15 18:27:10 -04:00
parent 20c1b7eb63
commit 9a54e3f530

View File

@ -666,6 +666,21 @@ int freeMemoryIfNeeded(void) {
return C_OK;
cant_free:
if (!cserver.delete_on_evict)
{
for (int idb = 0; idb < cserver.dbnum; ++idb)
{
redisDb *db = g_pserver->db[idb];
if (db->FStorageProvider())
{
serverLog(LL_WARNING, "Failed to evict keys, falling back to flushing entire cache. Consider increasing maxmemory-samples.");
db->removeAllCachedValues();
if (((mem_reported - zmalloc_used_memory()) + mem_freed) >= mem_tofree)
return C_OK;
}
}
}
/* We are here if we are not able to reclaim memory. There is only one
* last thing we can try: check if the lazyfree thread has jobs in queue
* and wait... */