forked from redis/redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have consistent behavior of SPUBLISH within multi/exec like regular c…
…ommand (redis#13276) This PR is based on the commits from PR redis#12944. Allow SPUBLISH command within multi/exec on replica Behavior on unstable: ``` 127.0.0.1:6380> CLUSTER NODES 39ce8aa20f1f0d91f1a88d976ee1926dfefcdf1a 127.0.0.1:6380@16380 myself,slave 8b0feb120b68aac489d6a5af9c77dc40d71bc792 0 0 0 connected 8b0feb120b68aac489d6a5af9c77dc40d71bc792 127.0.0.1:6379@16379 master - 0 1705091681202 0 connected 0-16383 127.0.0.1:6380> SPUBLISH hello world (integer) 0 127.0.0.1:6380> MULTI OK 127.0.0.1:6380(TX)> SPUBLISH hello world QUEUED 127.0.0.1:6380(TX)> EXEC (error) MOVED 866 127.0.0.1:6379 ``` With this change: ``` 127.0.0.1:6380> SPUBLISH hello world (integer) 0 127.0.0.1:6380> MULTI OK 127.0.0.1:6380(TX)> SPUBLISH hello world QUEUED 127.0.0.1:6380(TX)> EXEC 1) (integer) 0 ``` --------- Co-authored-by: Harkrishn Patro <[email protected]> Co-authored-by: oranagra <[email protected]>
- Loading branch information
1 parent
cfae246
commit 05da067
Showing
3 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# | ||
# Copyright (c) 2009-Present, Redis Ltd. | ||
# All rights reserved. | ||
# | ||
# Licensed under your choice of the Redis Source Available License 2.0 | ||
# (RSALv2) or the Server Side Public License v1 (SSPLv1). | ||
# | ||
# Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information. | ||
# | ||
|
||
start_cluster 1 1 {tags {external:skip cluster}} { | ||
set primary_id 0 | ||
set replica1_id 1 | ||
|
||
set primary [Rn $primary_id] | ||
set replica [Rn $replica1_id] | ||
|
||
test "Sharded pubsub publish behavior within multi/exec" { | ||
foreach {node} {primary replica} { | ||
set node [set $node] | ||
$node MULTI | ||
$node SPUBLISH ch1 "hello" | ||
$node EXEC | ||
} | ||
} | ||
|
||
test "Sharded pubsub within multi/exec with cross slot operation" { | ||
$primary MULTI | ||
$primary SPUBLISH ch1 "hello" | ||
$primary GET foo | ||
catch {[$primary EXEC]} err | ||
assert_match {CROSSSLOT*} $err | ||
} | ||
|
||
test "Sharded pubsub publish behavior within multi/exec with read operation on primary" { | ||
$primary MULTI | ||
$primary SPUBLISH foo "hello" | ||
$primary GET foo | ||
$primary EXEC | ||
} {0 {}} | ||
|
||
test "Sharded pubsub publish behavior within multi/exec with read operation on replica" { | ||
$replica MULTI | ||
$replica SPUBLISH foo "hello" | ||
catch {[$replica GET foo]} err | ||
assert_match {MOVED*} $err | ||
catch {[$replica EXEC]} err | ||
assert_match {EXECABORT*} $err | ||
} | ||
|
||
test "Sharded pubsub publish behavior within multi/exec with write operation on primary" { | ||
$primary MULTI | ||
$primary SPUBLISH foo "hello" | ||
$primary SET foo bar | ||
$primary EXEC | ||
} {0 OK} | ||
|
||
test "Sharded pubsub publish behavior within multi/exec with write operation on replica" { | ||
$replica MULTI | ||
$replica SPUBLISH foo "hello" | ||
catch {[$replica SET foo bar]} err | ||
assert_match {MOVED*} $err | ||
catch {[$replica EXEC]} err | ||
assert_match {EXECABORT*} $err | ||
} | ||
} |