used_memory > maxmemory: different behavior if a command is used in MULTI

42 views
Skip to first unread message

markus-z

unread,
Dec 10, 2021, 6:46:43 AM12/10/21
to Redis DB
I've created a scenario where `used_memory` is bigger than `maxmemory`
and where `maxmemory-policy` is set to `noeviction` and I'm confused
in the difference in behavior when I use a command wrapped in MULTI
and when I use it standalone.

When I try to delete a key inside MULTI, it won't work:
```
> MULTI
OK
> DEL 4kozfdoslif3ykqqsa69lolhpdhyki29fma16m7ukdo1e4iovegcohbjong28xuia77ps6nwxz7drjvvhrpte80q46y8uaq9zrfc
(error) OOM command not allowed when used memory > 'maxmemory'.
> EXEC
(error) EXECABORT Transaction discarded because of previous errors.
```

If I do the same as a standalone command, it does work:
```
> DEL 4kozfdoslif3ykqqsa69lolhpdhyki29fma16m7ukdo1e4iovegcohbjong28xuia77ps6nwxz7drjvvhrpte80q46y8uaq9zrfc
(integer) 1
```


Same behavior with the INFO command:
```
> MULTI
OK
> INFO memory
OOM command not allowed when used memory > 'maxmemory'.
> EXEC
(error) EXECABORT Transaction discarded because of previous errors.

INFO memory
# memory
[...]
```

What explains the difference in behavior?

Itamar Haber

unread,
Dec 10, 2021, 8:39:16 AM12/10/21
to Redis DB
Hello Markus,

Thanks for reaching out with this question - I can verify that it's happening. Looking at the code (server.c:~5396) we can see this comment that explains the reasoning underlying this behavior:

/* If a client is in MULTI/EXEC context, queuing may consume an unlimited
* amount of memory, so we want to stop that.
* However, we never want to reject DISCARD, or even EXEC (unless it
* contains denied commands, in which case is_denyoom_command is already
* set. */

That said, the exhibited behavior is wrong imo - at the very least, one should be able to use `DEL` in OOM regardless of whether one is in a transaction.

Please open a bug report about this (https://github.com/redis/redis/issues/new/choose), or let me know if you prefer that I do it, so the developers have visibility of this.

Cheers,
Itamar

markus-z

unread,
Dec 10, 2021, 9:27:36 AM12/10/21
to Redis DB
Hey Itamar,

I opened the bug report here https://github.com/redis/redis/issues/9926

Thanks for your quick response!
Reply all
Reply to author
Forward
0 new messages