Skip to content

Commit c909739

Browse files
committed
Issue redis#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 redis#4028.
1 parent 936ade8 commit c909739

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/evict.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,10 @@ int freeMemoryIfNeeded(void) {
380380
long long delta;
381381
int slaves = listLength(server.slaves);
382382

383-
/* We cannot free memory while clients are paused as this will require
384-
* evictions which modify the dataset and will break the guarantee that
385-
* data will be static while clients are paused. */
386-
if (clientsArePaused())
387-
goto cant_free;
383+
/* When clients are paused the dataset should be static not just from the
384+
* POV of clients not being able to write, but also from the POV of
385+
* expires and evictions of keys not being performed. */
386+
if (clientsArePaused()) return C_OK;
388387

389388
/* Check if we are over the memory usage limit. If we are not, no need
390389
* to subtract the slaves output buffers. We can just return ASAP. */

src/expire.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ void activeExpireCycle(int type) {
105105
int dbs_per_call = CRON_DBS_PER_CALL;
106106
long long start = ustime(), timelimit;
107107

108-
/* We cannot expire keys while clients are paused as the dataset is
109-
* supposed to be static. */
108+
/* When clients are paused the dataset should be static not just from the
109+
* POV of clients not being able to write, but also from the POV of
110+
* expires and evictions of keys not being performed. */
110111
if (clientsArePaused()) return;
111112

112113
if (type == ACTIVE_EXPIRE_CYCLE_FAST) {

0 commit comments

Comments
 (0)