From 4348d25fc45706ffd611d251d961eb3f1bf1ebde Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 17 Dec 2019 09:19:47 +0100 Subject: [PATCH] Add some comment to PR #6144 changes. --- src/cluster.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index a18543e0b..f603361cd 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -5599,14 +5599,22 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in * if it is a read command and when allow_reads_when_down is enabled. */ if (server.cluster->state != CLUSTER_OK) { if (!server.cluster_allow_reads_when_down) { + /* The cluster is configured to block commands when the + * cluster is down. */ if (error_code) *error_code = CLUSTER_REDIR_DOWN_STATE; return NULL; - } - - if (!(cmd->flags & CMD_READONLY) && !(cmd->proc == evalCommand) - && !(cmd->proc == evalShaCommand)) { + } else if (!(cmd->flags & CMD_READONLY) && !(cmd->proc == evalCommand) + && !(cmd->proc == evalShaCommand)) + { + /* The cluster is configured to allow read only commands + * but this command is neither readonly, nor EVAL or + * EVALSHA. */ if (error_code) *error_code = CLUSTER_REDIR_DOWN_RO_STATE; return NULL; + } else { + /* Fall through and allow the command to be executed: + * this happens when server.cluster_allow_reads_when_down is + * true and the command is a readonly command or EVAL / EVALSHA. */ } } -- GitLab