summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-06-23 11:42:25 +0200
committerantirez <antirez@gmail.com>2017-06-27 17:53:36 +0200
commit3669f96e115b3680ef671a830f319f4f510feb3f (patch)
tree2b89bac58b71e839d1d2c2ae8e94676571358d3d
parent896c4690dd478e1a733e142b8383774e6375a1b6 (diff)
downloadredis-3669f96e115b3680ef671a830f319f4f510feb3f.tar.gz
Issue #4027: unify comment and modify return value in freeMemoryIfNeeded().
It looks safer to return C_OK from freeMemoryIfNeeded() when clients are paused because returning C_ERR may prevent success of writes. It is possible that there is no difference in practice since clients cannot execute writes while clients are paused, but it looks more correct this way, at least conceptually. Related to PR #4028.
-rw-r--r--src/evict.c9
-rw-r--r--src/expire.c5
2 files changed, 7 insertions, 7 deletions
diff --git a/src/evict.c b/src/evict.c
index 77f63cba5..5ce5ca07f 100644
--- a/src/evict.c
+++ b/src/evict.c
@@ -380,11 +380,10 @@ int freeMemoryIfNeeded(void) {
long long delta;
int slaves = listLength(server.slaves);
- /* We cannot free memory while clients are paused as this will require
- * evictions which modify the dataset and will break the guarantee that
- * data will be static while clients are paused. */
- if (clientsArePaused())
- goto cant_free;
+ /* When clients are paused the dataset should be static not just from the
+ * POV of clients not being able to write, but also from the POV of
+ * expires and evictions of keys not being performed. */
+ if (clientsArePaused()) return C_OK;
/* Check if we are over the memory usage limit. If we are not, no need
* to subtract the slaves output buffers. We can just return ASAP. */
diff --git a/src/expire.c b/src/expire.c
index 14da78ec3..a02fe566a 100644
--- a/src/expire.c
+++ b/src/expire.c
@@ -105,8 +105,9 @@ void activeExpireCycle(int type) {
int dbs_per_call = CRON_DBS_PER_CALL;
long long start = ustime(), timelimit;
- /* We cannot expire keys while clients are paused as the dataset is
- * supposed to be static. */
+ /* When clients are paused the dataset should be static not just from the
+ * POV of clients not being able to write, but also from the POV of
+ * expires and evictions of keys not being performed. */
if (clientsArePaused()) return;
if (type == ACTIVE_EXPIRE_CYCLE_FAST) {