Fix OOM error not raised of functions (#10048)
OOM Error did not raise on functions due to a bug. Added test to verify the fix.
This commit is contained in:
parent
5460c10047
commit
78a62c0124
@ -3451,7 +3451,10 @@ int processCommand(client *c) {
|
||||
/* Save out_of_memory result at script start, otherwise if we check OOM
|
||||
* until first write within script, memory used by lua stack and
|
||||
* arguments might interfere. */
|
||||
if (c->cmd->proc == evalCommand || c->cmd->proc == evalShaCommand) {
|
||||
if (c->cmd->proc == evalCommand ||
|
||||
c->cmd->proc == evalShaCommand ||
|
||||
c->cmd->proc == fcallCommand)
|
||||
{
|
||||
server.script_oom = out_of_memory;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,20 @@ if {$is_eval == 1} {
|
||||
|
||||
start_server {tags {"scripting"}} {
|
||||
|
||||
test {Script - disallow write on OOM} {
|
||||
r FUNCTION create lua f1 replace { return redis.call('set', 'x', '1') }
|
||||
|
||||
r config set maxmemory 1
|
||||
|
||||
catch {[r fcall f1 1 k]} e
|
||||
assert_match {*command not allowed when used memory*} $e
|
||||
|
||||
catch {[r eval "redis.call('set', 'x', 1)" 0]} e
|
||||
assert_match {*command not allowed when used memory*} $e
|
||||
|
||||
r config set maxmemory 0
|
||||
}
|
||||
|
||||
test {EVAL - Does Lua interpreter replies to our requests?} {
|
||||
run_script {return 'hello'} 0
|
||||
} {hello}
|
||||
|
Loading…
x
Reference in New Issue
Block a user