From 7a73b7f168eb01c4cf43ab0e0348f0f2d9922cb5 Mon Sep 17 00:00:00 2001 From: valentino Date: Sat, 21 Sep 2019 20:58:57 +0300 Subject: DISCARD should not fail during OOM discard command should not fail during OOM, otherwise client MULTI state will not be cleared. --- src/server.c | 2 +- tests/unit/multi.tcl | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/server.c b/src/server.c index 7882b0d99..3737c3352 100644 --- a/src/server.c +++ b/src/server.c @@ -3411,7 +3411,7 @@ int processCommand(client *c) { * is in MULTI/EXEC context? Error. */ if (out_of_memory && (c->cmd->flags & CMD_DENYOOM || - (c->flags & CLIENT_MULTI && c->cmd->proc != execCommand))) { + (c->flags & CLIENT_MULTI && c->cmd->proc != execCommand && c->cmd->proc != discardCommand))) { flagTransaction(c); addReply(c, shared.oomerr); return C_OK; diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 6655bf62c..9fcef71d6 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -306,4 +306,18 @@ start_server {tags {"multi"}} { } close_replication_stream $repl } + + test {DISCARD should not fail during OOM} { + set rd [redis_deferring_client] + $rd config set maxmemory 1 + assert {[$rd read] eq {OK}} + r multi + catch {r set x 1} e + assert_match {OOM*} $e + r discard + $rd config set maxmemory 0 + assert {[$rd read] eq {OK}} + $rd close + r ping + } {PONG} } -- cgit v1.2.1