Redis "OOM command not allowed when used memory > maxmemory" in CI
Redis reached its maxmemory limit and the maxmemory-policy is noeviction, so it refuses writes with "OOM command not allowed when used memory > maxmemory." This is a Redis-level cap, not the kernel OOM killer.
What this error means
Writes fail with "OOM command not allowed when used memory > maxmemory." once a test loads enough data, while reads and deletes still work.
(error) OOM command not allowed when used memory > 'maxmemory'.
# python:
redis.exceptions.OutOfMemoryError: OOM command not allowed when used memory
> 'maxmemory'.Common causes
maxmemory reached under noeviction
With the default noeviction policy, once used_memory exceeds maxmemory, Redis rejects any command that adds data instead of evicting keys.
A low maxmemory for the test dataset
A tight maxmemory (or a small container memory limit that Redis derives from) fills quickly when tests write many keys.
How to fix it
Raise maxmemory or set an eviction policy
For a cache-style test, allow eviction so old keys are dropped instead of rejecting writes.
redis-cli config set maxmemory 256mb
redis-cli config set maxmemory-policy allkeys-lruConfigure the service for the workload
Set a maxmemory that fits the test dataset (or leave it at 0 for unbounded in CI).
services:
redis:
image: redis:7
options: --maxmemory 256mb --maxmemory-policy allkeys-lru
ports: ['6379:6379']How to prevent it
- Pick a maxmemory-policy that suits the test (eviction for caches).
- Size maxmemory to the dataset the suite writes.
- Flush between test files so memory does not accumulate.