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.
This commit is contained in:
parent
87789fae0b
commit
2e1979a21e
@ -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;
|
||||
}
|
||||
|
14
src/evict.c
14
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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -174,7 +174,8 @@ tags "modules" {
|
||||
|
||||
# Note whenever there's double notification: SET with EX issues two separate
|
||||
# notifications: one for "set" and one for "expire"
|
||||
# "config set" should not be here, see https://github.com/redis/redis/issues/10014
|
||||
# Note that although CONFIG SET maxmemory is called in this flow (see issue #10014),
|
||||
# eviction will happen and will not induce propagation of the CONFIG command (see #10019).
|
||||
assert_replication_stream $repl {
|
||||
{select *}
|
||||
{multi}
|
||||
@ -198,7 +199,6 @@ tags "modules" {
|
||||
{del asdf*}
|
||||
{incr notifications}
|
||||
{del asdf*}
|
||||
{config set maxmemory 1}
|
||||
{multi}
|
||||
{incr notifications}
|
||||
{set asdf4 4}
|
||||
|
Loading…
x
Reference in New Issue
Block a user