Skip to content

Commit 936ade8

Browse files
authored
Merge pull request redis#4028 from zintrepid/prevent_expirations_while_paused
Prevent expirations and evictions while paused
2 parents 8b768e8 + a3e53cf commit 936ade8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/evict.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ 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;
388+
383389
/* Check if we are over the memory usage limit. If we are not, no need
384390
* to subtract the slaves output buffers. We can just return ASAP. */
385391
mem_reported = zmalloc_used_memory();

src/expire.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ 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. */
110+
if (clientsArePaused()) return;
111+
108112
if (type == ACTIVE_EXPIRE_CYCLE_FAST) {
109113
/* Don't start a fast cycle if the previous cycle did not exited
110114
* for time limt. Also don't repeat a fast cycle for the same period

0 commit comments

Comments
 (0)