summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhaozhao.zz <276441700@qq.com>2022-01-04 19:08:10 +0800
committerGitHub <noreply@github.com>2022-01-04 13:08:10 +0200
commit2e1979a21e0d30e8dacb86617f891fb004700fbc (patch)
tree2c6eeeaf14d29e5abb1a67507bb617a80f1b9099 /src
parent87789fae0b767e47fef78ee994434554f2bf2f31 (diff)
downloadredis-2e1979a21e0d30e8dacb86617f891fb004700fbc.tar.gz
use startEvictionTimeProc() in config set maxmemory (#10019)
This would mean that the effects of `CONFIG SET maxmemory` may not be visible once the command returns. That could anyway happen since incremental eviction was added in redis 6.2 (see #7653) We do this to fix one of the propagation bugs about eviction see #9890 and #10014.
Diffstat (limited to 'src')
-rw-r--r--src/config.c2
-rw-r--r--src/evict.c14
-rw-r--r--src/server.h2
3 files changed, 11 insertions, 7 deletions
diff --git a/src/config.c b/src/config.c
index 79e43c301..1a7337883 100644
--- a/src/config.c
+++ b/src/config.c
@@ -2252,7 +2252,7 @@ static int updateMaxmemory(const char **err) {
if (server.maxmemory < used) {
serverLog(LL_WARNING,"WARNING: the new maxmemory value set via CONFIG SET (%llu) is smaller than the current memory usage (%zu). This will result in key eviction and/or the inability to accept new write commands depending on the maxmemory-policy.", server.maxmemory, used);
}
- performEvictions();
+ startEvictionTimeProc();
}
return 1;
}
diff --git a/src/evict.c b/src/evict.c
index 9d0557df1..933141638 100644
--- a/src/evict.c
+++ b/src/evict.c
@@ -466,6 +466,14 @@ static int evictionTimeProc(
return AE_NOMORE;
}
+void startEvictionTimeProc(void) {
+ if (!isEvictionProcRunning) {
+ isEvictionProcRunning = 1;
+ aeCreateTimeEvent(server.el, 0,
+ evictionTimeProc, NULL, NULL);
+ }
+}
+
/* Check if it's safe to perform evictions.
* Returns 1 if evictions can be performed
* Returns 0 if eviction processing should be skipped
@@ -712,11 +720,7 @@ int performEvictions(void) {
* memory, don't want to spend too much time here. */
if (elapsedUs(evictionTimer) > eviction_time_limit_us) {
// We still need to free memory - start eviction timer proc
- if (!isEvictionProcRunning) {
- isEvictionProcRunning = 1;
- aeCreateTimeEvent(server.el, 0,
- evictionTimeProc, NULL, NULL);
- }
+ startEvictionTimeProc();
break;
}
}
diff --git a/src/server.h b/src/server.h
index 7aa73ab73..bbeb2ad8b 100644
--- a/src/server.h
+++ b/src/server.h
@@ -3044,7 +3044,7 @@ unsigned long LFUDecrAndReturn(robj *o);
#define EVICT_RUNNING 1
#define EVICT_FAIL 2
int performEvictions(void);
-
+void startEvictionTimeProc(void);
/* Keys hashing / comparison functions for dict.c hash tables. */
uint64_t dictSdsHash(const void *key);