Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug the error "OOM command not allowed when used memory > 'maxmemory'" in Redis?

Tags:

redis

I'm getting "OOM command not allowed" when trying to set a key, maxmemory is set to 500M with maxmemory-policy "volatile-lru", I'm setting TTL for each key sent to redis.

INFO command returns : used_memory_human:809.22M

  1. If maxmemory is set to 500M, how did I reached 809M ?
  2. INFO command does not show any Keyspaces , how is it possible ?
  3. KEYS * returns "(empty list or set)" ,I've tried to change db number , still no keys found.

Here is info command output:

redis-cli -p 6380 redis 127.0.0.1:6380> info # Server redis_version:2.6.4 redis_git_sha1:00000000 redis_git_dirty:0 redis_mode:standalone os:Linux 2.6.32-358.14.1.el6.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.7 process_id:28291 run_id:229a2ee688bdbf677eaed24620102e7060725350 tcp_port:6380 uptime_in_seconds:1492488 uptime_in_days:17 lru_clock:1429357  # Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0  # Memory used_memory:848529904 used_memory_human:809.22M used_memory_rss:863551488 used_memory_peak:848529192 used_memory_peak_human:809.22M used_memory_lua:31744 mem_fragmentation_ratio:1.02 mem_allocator:jemalloc-3.0.0  # Persistence loading:0 rdb_changes_since_last_save:0 rdb_bgsave_in_progress:0 rdb_last_save_time:1375949883 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:-1 rdb_current_bgsave_time_sec:-1 aof_enabled:0 aof_rewrite_in_progress:0 aof_rewrite_scheduled:0 aof_last_rewrite_time_sec:-1 aof_current_rewrite_time_sec:-1 aof_last_bgrewrite_status:ok  # Stats total_connections_received:3 total_commands_processed:8 instantaneous_ops_per_sec:0 rejected_connections:0 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0  # Replication role:master connected_slaves:0  # CPU used_cpu_sys:18577.25 used_cpu_user:1376055.38 used_cpu_sys_children:0.00 used_cpu_user_children:0.00  # Keyspace redis 127.0.0.1:6380> 
like image 286
Ranch Avatar asked Aug 25 '13 15:08

Ranch


People also ask

How do I fix the exception oom command not allowed when used memory Maxmemory?

To resolve this error and to prevent clients from receiving OOM command not allowed error messages, do some combination of the following: Set a TTL value for keys on your node. Update the parameter group to use a different maxmemory-policy parameter. Delete some existing keys manually to free up memory.

What happens if Redis runs out of memory?

If virtual memory in Redis is disabled (the default) and the maxmemory parameter is set (the default), Redis will not use any more memory than maxmemory allows. If you turn maxmemory off, Redis will start using virtual memory (i.e. swap), and performance will drop tremendously.

How do I check Redis memory?

Redis Key Memory Info You can use two main commands if you want to view the keys in a Redis datastore. Dbsize – The Redis dbsize command shows the total number of valid keys in a specific database. Info keyspace – This command shows the keys in each database available in the Redis cluster.

What does Maxmemory mean?

What does it mean? The OOM command not allowed when used memory > 'maxmemory' error means that Redis was configured with a memory limit and that particular limit was reached. In other words: its memory is full, it can't store any new data. You can see the memory values by using the redis CLI tool.


2 Answers

Redis' maxmemory volatile-lru policy can fail to free enough memory if the maxmemory limit is already used by the non-volatile keys.

like image 192
ColinM Avatar answered Sep 26 '22 04:09

ColinM


Any chance you changed the number of databases? If you use a very large number then the initial memory usage may be high

like image 44
Eyal Post Avatar answered Sep 22 '22 04:09

Eyal Post