From ad174ab3520c92665bb9e718ec600ea4c5baf895 Mon Sep 17 00:00:00 2001 From: John Sully Date: Tue, 2 Jun 2020 17:21:41 -0400 Subject: [PATCH] Merge error, server always flushes on eviction Former-commit-id: 9b3b0c9a40ab5dcdac9620f0fbad84887cc9c832 --- src/evict.cpp | 4 ++-- tests/unit/flash.tcl | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/evict.cpp b/src/evict.cpp index 8429ea3db..a6dfd9ba9 100644 --- a/src/evict.cpp +++ b/src/evict.cpp @@ -678,7 +678,7 @@ int freeMemoryIfNeeded(bool fPreSnapshot) { result = C_OK; cant_free: - if (!cserver.delete_on_evict) + if (!cserver.delete_on_evict && result != C_OK) { for (int idb = 0; idb < cserver.dbnum; ++idb) { @@ -688,7 +688,7 @@ cant_free: 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; + result = C_OK; } } } diff --git a/tests/unit/flash.tcl b/tests/unit/flash.tcl index d342baecf..374bb648e 100644 --- a/tests/unit/flash.tcl +++ b/tests/unit/flash.tcl @@ -130,6 +130,9 @@ start_server [list tags {flash} overrides [list storage-provider {flash ./rocks. } err assert {$err == {OK}} } + if {[log_file_matches [srv 0 stdout] "*Failed to evict*"]} { + fail "Server did not evict cleanly (detected full flush)" + } r set last val set dbsize [r dbsize] assert {[s used_memory] < $limit+4096}