1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-18 00:20:57 +03:00

fix(txpipeline): should return error on multi/exec on multiple slots

This commit is contained in:
Nedyalko Dyakov
2025-06-16 18:27:57 +03:00
parent 82b00cc520
commit c6d385a63e

View File

@ -1504,6 +1504,16 @@ func (c *ClusterClient) processTxPipeline(ctx context.Context, cmds []Cmder) err
} }
cmdsMap := c.mapCmdsBySlot(cmds) cmdsMap := c.mapCmdsBySlot(cmds)
// TxPipeline does not support cross slot transaction.
if len(cmdsMap) > 1 {
err := fmt.Errorf("redis: CROSSSLOT Keys in request don't hash to the same slot")
setCmdsErr(cmds, err)
return err
}
if len(cmdsMap) == 0 {
return nil
}
for slot, cmds := range cmdsMap { for slot, cmds := range cmdsMap {
node, err := state.slotMasterNode(slot) node, err := state.slotMasterNode(slot)
if err != nil { if err != nil {