diff options
author | zhaozhao.zz <276441700@qq.com> | 2022-03-08 22:53:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 16:53:11 +0200 |
commit | 728e62523e1a7998ed30be2ab0a6947390ff6a87 (patch) | |
tree | b2a3afef62602b489548cde795d1a8a6e90dacb9 /src/script.c | |
parent | b3fe4f31a2b705abef147edf4b625f53e2dc7c9f (diff) | |
download | redis-728e62523e1a7998ed30be2ab0a6947390ff6a87.tar.gz |
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:
Diffstat (limited to 'src/script.c')
-rw-r--r-- | src/script.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/script.c b/src/script.c index d78d9fd6b..a34f53e66 100644 --- a/src/script.c +++ b/src/script.c @@ -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; } |