SUNSUBSCRIBE on replica should not return MOVED to master

This commit is contained in:
俞跃 2024-11-05 17:49:51 +08:00
parent 9906daf5c9
commit e35bc21637
2 changed files with 11 additions and 2 deletions

View File

@ -1131,8 +1131,9 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
margv = ms->commands[i].argv;
/* Only valid for sharded pubsub as regular pubsub can operate on any node and bypasses this layer. */
if (!pubsubshard_included &&
doesCommandHaveChannelsWithFlags(mcmd, CMD_CHANNEL_PUBLISH | CMD_CHANNEL_SUBSCRIBE))
if (!pubsubshard_included && (mcmd->proc == ssubscribeCommand ||
mcmd->proc == sunsubscribeCommand ||
mcmd->proc == spublishCommand))
{
pubsubshard_included = 1;
}

View File

@ -63,4 +63,12 @@ start_cluster 1 1 {tags {external:skip cluster}} {
catch {[$replica EXEC]} err
assert_match {EXECABORT*} $err
}
test "Sharded pubsub sunsubscribe behavior on replica" {
$replica SUNSUBSCRIBE foo
$replica MULTI
$replica SUNSUBSCRIBE foo
$replica EXEC
}
}