Handle all CLUSTER_REDIR_ error code when verifying script. (#12707)

Clarify the errors related to the cluster mode in the script, return the command that encountered an execution error along with the specific error message.

---------

Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
This commit is contained in:
Chen Tianjie 2023-11-06 17:48:58 +08:00 committed by GitHub
parent 28b6155ba5
commit 282b82e9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -437,7 +437,22 @@ static int scriptVerifyClusterState(scriptRunCtx *run_ctx, client *c, client *or
} else if (error_code == CLUSTER_REDIR_DOWN_STATE) {
*err = sdsnew("Script attempted to execute a command while the "
"cluster is down");
} else if (error_code == CLUSTER_REDIR_CROSS_SLOT) {
*err = sdscatfmt(sdsempty(),
"Command '%S' in script attempted to access keys that don't hash to the same slot",
c->cmd->fullname);
} else if (error_code == CLUSTER_REDIR_UNSTABLE) {
/* The request spawns multiple keys in the same slot,
* but the slot is not "stable" currently as there is
* a migration or import in progress. */
*err = sdscatfmt(sdsempty(),
"Unable to execute command '%S' in script "
"because undeclared keys were accessed during rehashing of the slot",
c->cmd->fullname);
} else if (error_code == CLUSTER_REDIR_DOWN_UNBOUND) {
*err = sdsnew("Script attempted to access a slot not served");
} else {
/* error_code == CLUSTER_REDIR_MOVED || error_code == CLUSTER_REDIR_ASK */
*err = sdsnew("Script attempted to access a non local key in a "
"cluster node");
}