Unverified Commit 728e6252 authored by zhaozhao.zz's avatar zhaozhao.zz Committed by GitHub
Browse files

script should not allow may-replicate commands when client pause write (#10364)

In some special commands like eval_ro / fcall_ro we allow no-writes commands.
But may-replicate commands are no-writes too, that leads crash when client pause write:
parent b3fe4f31
......@@ -387,6 +387,16 @@ static int scriptVerifyWriteCommandAllow(scriptRunCtx *run_ctx, char **err) {
return C_OK;
}
static int scriptVerifyMayReplicate(scriptRunCtx *run_ctx, char **err) {
if (run_ctx->c->cmd->flags & CMD_MAY_REPLICATE &&
server.client_pause_type == CLIENT_PAUSE_WRITE) {
*err = sdsnew("May-replicate commands are not allowed when client pause write.");
return C_ERR;
}
return C_OK;
}
static int scriptVerifyOOM(scriptRunCtx *run_ctx, char **err) {
if (run_ctx->flags & SCRIPT_ALLOW_OOM) {
/* Allow running any command even if OOM reached */
......@@ -528,6 +538,10 @@ void scriptCall(scriptRunCtx *run_ctx, robj* *argv, int argc, sds *err) {
goto error;
}
if (scriptVerifyMayReplicate(run_ctx, err) != C_OK) {
goto error;
}
if (scriptVerifyOOM(run_ctx, err) != C_OK) {
goto error;
}
......
......@@ -86,6 +86,14 @@ start_server {tags {"pause network"}} {
$rd close
}
test "Test may-replicate commands are rejected in ro script by pause RO" {
r client PAUSE 60000 WRITE
assert_error {ERR May-replicate commands are not allowed when client pause write*} {
r EVAL_RO "return redis.call('publish','ch','msg')" 0
}
r client unpause
}
test "Test multiple clients can be queued up and unblocked" {
r client PAUSE 60000 WRITE
set clients [list [redis_deferring_client] [redis_deferring_client] [redis_deferring_client]]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment