Skip to content

Check cluster_enabled in readwriteCommand just like readonlyCommand.#9015

Merged
madolson merged 1 commit into
redis:unstablefrom
enjoy-binbin:consistent_readwrite
Jun 21, 2021
Merged

Check cluster_enabled in readwriteCommand just like readonlyCommand.#9015
madolson merged 1 commit into
redis:unstablefrom
enjoy-binbin:consistent_readwrite

Conversation

@enjoy-binbin

@enjoy-binbin enjoy-binbin commented May 31, 2021

Copy link
Copy Markdown
Contributor

It seems that readwrite can only be used in cluster mode. So i add a check just like readonly command. Just a cleanup that consistent check

rewrite doc: https://redis.io/commands/readwrite

/* The READONLY command is used by clients to enter the read-only mode.
 * In this mode slaves will not redirect clients as long as clients access
 * with read-only commands to keys that are served by the slave's master. */
void readonlyCommand(client *c) {
    if (server.cluster_enabled == 0) {
        addReplyError(c,"This instance has cluster support disabled");
        return;
    }
    c->flags |= CLIENT_READONLY;
    addReply(c,shared.ok);
}

/* The READWRITE command just clears the READONLY command state. */
void readwriteCommand(client *c) {
    +if (server.cluster_enabled == 0) {
    +   addReplyError(c,"This instance has cluster support disabled");
    +    return;
    +}
    c->flags &= ~CLIENT_READONLY;
    addReply(c,shared.ok);
}

Comment thread src/cluster.c

@madolson madolson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like a major change to me

@madolson madolson merged commit f004073 into redis:unstable Jun 21, 2021
@enjoy-binbin enjoy-binbin deleted the consistent_readwrite branch June 22, 2021 02:03
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants