Skip to content

Commit

Permalink
fix: change error message
Browse files Browse the repository at this point in the history
Signed-off-by: proost <[email protected]>
  • Loading branch information
proost committed Dec 29, 2024
1 parent e428686 commit 39df990
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ static int scriptVerifyWriteCommandAllow(scriptRunCtx *run_ctx, char **err) {

/*
* If client is readonly and server is a replica, we should not allow write-commands.
* we should redirect the client.
*/
if (run_ctx->original_client->flag.readonly && server.primary_host) {
client *c = run_ctx->c;
Expand All @@ -392,9 +391,8 @@ static int scriptVerifyWriteCommandAllow(scriptRunCtx *run_ctx, char **err) {
clusterNode *n = getNodeByQuery(c, c->cmd, c->argv, c->argc, &hashslot, &error_code);
if (n == NULL || !clusterNodeIsMyself(n)) {
if (error_code == CLUSTER_REDIR_MOVED || error_code == CLUSTER_REDIR_ASK) {
int port = clusterNodeClientPort(n, connIsTLS(original_c->conn));
*err = sdscatprintf(sdsempty(), "-%s %d %s:%d", (error_code == CLUSTER_REDIR_ASK) ? "ASK" : "MOVED",
hashslot, clusterNodePreferredEndpoint(n, c), port);
*err = sdsnew("Script attempted to access a non local key in a "
"cluster node");
return C_ERR;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/cluster/scripting.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ start_cluster 2 2 {tags {external:skip cluster}} {
$replica2 eval "redis.call('set', 'foo', 'bar')" 0
} e

assert_match {*MOVED*} $e
assert_match {*Script attempted to access a non local ke*} $e
}

test "Read-only client that sends lua script which has write command on replica get ASK error during migration" {
Expand All @@ -130,6 +130,6 @@ start_cluster 2 2 {tags {external:skip cluster}} {
$replica2 eval "redis.call('set', 'foo', 'bar')" 0
} e

assert_match {*ASK*} $e
assert_match {*Script attempted to access a non local ke*} $e
}
}

0 comments on commit 39df990

Please sign in to comment.