redis memory_error ai_generated true

OOM command not allowed when used memory > 'maxmemory'

ID: redis/oom-maxmemory

Also available as: JSON · Markdown
85%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7 active

Root Cause

Redis memory limit reached and eviction policy does not allow the operation.

generic

Workarounds

  1. 90% success Set appropriate eviction policy
    CONFIG SET maxmemory-policy allkeys-lru  # evict least-recently-used keys

    Sources: https://redis.io/docs/

  2. 85% success Increase maxmemory if the server has available RAM
    CONFIG SET maxmemory 4gb
  3. 88% success Analyze memory usage to find large keys
    redis-cli --bigkeys  # finds largest keys per type; redis-cli MEMORY USAGE key_name

Dead Ends

Common approaches that don't work:

  1. Remove maxmemory limit entirely 85% fail

    Without limits, Redis grows until the OS OOM killer terminates it, losing all data

  2. Flush all data (FLUSHALL) to free memory 72% fail

    Destroys all data. Only appropriate if data is a rebuildable cache.