fix maxmemory config warning

the warning condition was if usage > limit (saying it'll cause eviction
or oom), but in fact the eviction and oom depends on used minus slave
buffers.

other than fixing the condition, i add info about the current usage and
limit, which may be useful when looking at the log.
This commit is contained in:
Oran Agra 2020-02-06 09:23:22 +02:00 committed by antirez
parent 8e7282eb3e
commit 1333a46b7e

View File

@ -1995,8 +1995,9 @@ static int updateMaxmemory(long long val, long long prev, char **err) {
UNUSED(prev); UNUSED(prev);
UNUSED(err); UNUSED(err);
if (val) { if (val) {
if ((unsigned long long)val < zmalloc_used_memory()) { size_t used = zmalloc_used_memory()-freeMemoryGetNotCountedMemory();
serverLog(LL_WARNING,"WARNING: the new maxmemory value set via CONFIG SET is smaller than the current memory usage. This will result in key eviction and/or the inability to accept new write commands depending on the maxmemory-policy."); if ((unsigned long long)val < 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);
} }
freeMemoryIfNeededAndSafe(); freeMemoryIfNeededAndSafe();
} }