Skip to content

Commit c6d385a

Browse files
committed
fix(txpipeline): should return error on multi/exec on multiple slots
1 parent 82b00cc commit c6d385a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

osscluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,16 @@ func (c *ClusterClient) processTxPipeline(ctx context.Context, cmds []Cmder) err
15041504
}
15051505

15061506
cmdsMap := c.mapCmdsBySlot(cmds)
1507+
// TxPipeline does not support cross slot transaction.
1508+
if len(cmdsMap) > 1 {
1509+
err := fmt.Errorf("redis: CROSSSLOT Keys in request don't hash to the same slot")
1510+
setCmdsErr(cmds, err)
1511+
return err
1512+
}
1513+
if len(cmdsMap) == 0 {
1514+
return nil
1515+
}
1516+
15071517
for slot, cmds := range cmdsMap {
15081518
node, err := state.slotMasterNode(slot)
15091519
if err != nil {

0 commit comments

Comments
 (0)