diff options
Diffstat (limited to 'src/evict.c')
-rw-r--r-- | src/evict.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/evict.c b/src/evict.c index a10c2d20e..6e2f8af72 100644 --- a/src/evict.c +++ b/src/evict.c @@ -484,6 +484,10 @@ static int isSafeToPerformEvictions(void) { * expires and evictions of keys not being performed. */ if (checkClientPauseTimeoutAndReturnIfPaused()) return 0; + /* We cannot evict if we already have stuff to propagate (for example, + * CONFIG SET maxmemory inside a MULTI/EXEC) */ + if (server.also_propagate.numops != 0) return 0; + return 1; } @@ -561,6 +565,13 @@ int performEvictions(void) { monotime evictionTimer; elapsedStart(&evictionTimer); + /* Unlike active-expire and blocked client, we can reach here from 'CONFIG SET maxmemory' + * so we have to back-up and restore server.core_propagates. */ + int prev_core_propagates = server.core_propagates; + serverAssert(server.also_propagate.numops == 0); + server.core_propagates = 1; + server.propagate_no_multi = 1; + while (mem_freed < (long long)mem_tofree) { int j, k, i; static unsigned int next_db = 0; @@ -648,7 +659,6 @@ int performEvictions(void) { if (bestkey) { db = server.db+bestdbid; robj *keyobj = createStringObject(bestkey,sdslen(bestkey)); - propagateExpire(db,keyobj,server.lazyfree_lazy_eviction); /* We compute the amount of memory freed by db*Delete() alone. * It is possible that actually the memory needed to propagate * the DEL in AOF and replication link is greater than the one @@ -673,6 +683,7 @@ int performEvictions(void) { signalModifiedKey(NULL,db,keyobj); notifyKeyspaceEvent(NOTIFY_EVICTED, "evicted", keyobj, db->id); + propagateDeletion(db,keyobj,server.lazyfree_lazy_eviction); decrRefCount(keyobj); keys_freed++; @@ -729,6 +740,14 @@ cant_free: } } + serverAssert(server.core_propagates); /* This function should not be re-entrant */ + + /* Propagate all DELs */ + propagatePendingCommands(); + + server.core_propagates = prev_core_propagates; + server.propagate_no_multi = 0; + latencyEndMonitor(latency); latencyAddSampleIfNeeded("eviction-cycle",latency); |