Warning when maxmemory setting is wrong #429

Closed
dspezia opened this Issue Apr 3, 2012 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

dspezia commented Apr 3, 2012

Hi Salvatore/Pieter,

some people have issues with maxmemory setting.
See http://stackoverflow.com/questions/9987832/redis-with-resque-and-rails-err-command-not-allowed-when-used-memory-maxmemo

There are 3 situations IMO:

  • some people don't read the documentation and think the setting is in MB or GB. So they set something like 1 byte for maxmemory in the configuration file.
  • some people try to enforce a maxmemory limit in the configuration file while they already have a dump file. The limit they set is actually smaller than the data they already have.
  • some people may try to dynamically change the maxmemory setting and set a limit which is lower than the data they already have in memory.

Currently, Redis is silent in these situations, until the first set operation.

The third situation can be a genuine one (meaning that the users may actually want to decrease the memory consumption by setting a more aggressive memory reclamation policy). However, I believe the 2 first ones are clearly mistakes from the users and should be signaled.

I think an explicit warning in the log file at Redis startup time could be helpful:

  • once the dump file is loaded (or if there is no dump file to load), check used_memory
  • if maxmemory is enforced and used_memory > maxmemory, issue a warning about the maxmemory setting

Regards,
Didier.

Owner

antirez commented Apr 8, 2012

Thank you Didier, moved into the 2.6 milestone, so this will be addressed ASAP. More news to come.

antirez added a commit that referenced this issue Oct 5, 2012

Warn when configured maxmemory value seems odd.
This commit warns the user with a log at "warning" level if:

1) After the server startup the maxmemory limit was found to be < 1MB.
2) After a CONFIG SET command modifying the maxmemory setting the limit
is set to a value that is smaller than the currently used memory.

The behaviour of the Redis server is unmodified, and this wil not make
the CONFIG SET command or a wrong configuration in redis.conf less
likely to create problems, but at least this will make aware most users
about a possbile error they committed without resorting to external
help.

However no warning is issued if, as a result of loading the AOF or RDB
file, we are very near the maxmemory setting, or key eviction will be
needed in order to go under the specified maxmemory setting. The reason
is that in servers configured as a cache with an aggressive
maxmemory-policy most of the times restarting the server will cause this
condition to happen if persistence is not switched off.

This fixes issue #429.
Owner

antirez commented Oct 5, 2012

Hey dider, I just did what you suggested, but in a slightly different way as commented in the commit. Thanks! Closing the issue.

@antirez antirez closed this Oct 5, 2012

antirez added a commit that referenced this issue Oct 5, 2012

Warn when configured maxmemory value seems odd.
This commit warns the user with a log at "warning" level if:

1) After the server startup the maxmemory limit was found to be < 1MB.
2) After a CONFIG SET command modifying the maxmemory setting the limit
is set to a value that is smaller than the currently used memory.

The behaviour of the Redis server is unmodified, and this wil not make
the CONFIG SET command or a wrong configuration in redis.conf less
likely to create problems, but at least this will make aware most users
about a possbile error they committed without resorting to external
help.

However no warning is issued if, as a result of loading the AOF or RDB
file, we are very near the maxmemory setting, or key eviction will be
needed in order to go under the specified maxmemory setting. The reason
is that in servers configured as a cache with an aggressive
maxmemory-policy most of the times restarting the server will cause this
condition to happen if persistence is not switched off.

This fixes issue #429.

Hailei pushed a commit to Hailei/redis that referenced this issue Aug 29, 2014

Hailei pushed a commit to Hailei/redis that referenced this issue Aug 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment