Skip to content

Commit e0b122a

Browse files
committed
fix mget test
1 parent f1c7f62 commit e0b122a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

osscluster_router.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"reflect"
7+
"strings"
78
"sync"
89
"time"
910

@@ -418,10 +419,13 @@ func (c *ClusterClient) aggregateResponses(cmd Cmder, cmds []Cmder, policy *rout
418419
// createAggregator creates the appropriate response aggregator
419420
func (c *ClusterClient) createAggregator(policy *routing.CommandPolicy, cmd Cmder, isKeyed bool) routing.ResponseAggregator {
420421
if policy != nil {
421-
// For multi-shard commands that operate on multiple keys (like MGET),
422-
// use keyed aggregator even if policy says all_succeeded
423-
if policy.Request == routing.ReqMultiShard && isKeyed {
424-
return routing.NewDefaultAggregator(true)
422+
// For specific multi-shard commands that need keyed aggregation despite having
423+
// all_succeeded policy (like MGET which needs to preserve key order)
424+
if policy.Request == routing.ReqMultiShard && policy.Response == routing.RespAllSucceeded && isKeyed {
425+
cmdName := strings.ToLower(cmd.Name())
426+
if cmdName == "mget" {
427+
return routing.NewDefaultAggregator(true)
428+
}
425429
}
426430
return routing.NewResponseAggregator(policy.Response, cmd.Name())
427431
}

0 commit comments

Comments
 (0)