@@ -645,8 +645,10 @@ func (c *clusterClient) pickMulti(ctx context.Context, multi []Completed) (*conn
645
645
646
646
func (c * clusterClient ) doresultfn (
647
647
ctx context.Context , results * redisresults , retries * connretry , mu * sync.Mutex , cc conn , cIndexes []int , commands []Completed , resps []RedisResult , attempts int ,
648
- ) {
648
+ ) (clean bool ) {
649
+ clean = true
649
650
for i , resp := range resps {
651
+ clean = clean && resp .NonRedisError () == nil
650
652
ii := cIndexes [i ]
651
653
cm := commands [i ]
652
654
results .s [ii ] = resp
@@ -658,7 +660,6 @@ func (c *clusterClient) doresultfn(
658
660
if ! c .retry || ! cm .IsReadOnly () {
659
661
continue
660
662
}
661
-
662
663
retryDelay = c .retryHandler .RetryDelay (attempts , cm , resp .Error ())
663
664
} else {
664
665
nc = c .redirectOrNew (addr , cc , cm .Slot (), mode )
@@ -685,22 +686,24 @@ func (c *clusterClient) doresultfn(
685
686
mu .Unlock ()
686
687
}
687
688
}
689
+ return clean
688
690
}
689
691
690
692
func (c * clusterClient ) doretry (
691
693
ctx context.Context , cc conn , results * redisresults , retries * connretry , re * retry , mu * sync.Mutex , wg * sync.WaitGroup , attempts int ,
692
694
) {
695
+ clean := true
693
696
if len (re .commands ) != 0 {
694
697
resps := cc .DoMulti (ctx , re .commands ... )
695
- c .doresultfn (ctx , results , retries , mu , cc , re .cIndexes , re .commands , resps .s , attempts )
698
+ clean = c .doresultfn (ctx , results , retries , mu , cc , re .cIndexes , re .commands , resps .s , attempts )
696
699
resultsp .Put (resps )
697
700
}
698
701
if len (re .cAskings ) != 0 {
699
702
resps := askingMulti (cc , ctx , re .cAskings )
700
- c .doresultfn (ctx , results , retries , mu , cc , re .aIndexes , re .cAskings , resps .s , attempts )
703
+ clean = c .doresultfn (ctx , results , retries , mu , cc , re .aIndexes , re .cAskings , resps .s , attempts ) && clean
701
704
resultsp .Put (resps )
702
705
}
703
- if ctx . Err () == nil {
706
+ if clean {
704
707
retryp .Put (re )
705
708
}
706
709
wg .Done ()
@@ -928,8 +931,10 @@ func (c *clusterClient) pickMultiCache(ctx context.Context, multi []CacheableTTL
928
931
929
932
func (c * clusterClient ) resultcachefn (
930
933
ctx context.Context , results * redisresults , retries * connretrycache , mu * sync.Mutex , cc conn , cIndexes []int , commands []CacheableTTL , resps []RedisResult , attempts int ,
931
- ) {
934
+ ) (clean bool ) {
935
+ clean = true
932
936
for i , resp := range resps {
937
+ clean = clean && resp .NonRedisError () == nil
933
938
ii := cIndexes [i ]
934
939
cm := commands [i ]
935
940
results .s [ii ] = resp
@@ -968,22 +973,24 @@ func (c *clusterClient) resultcachefn(
968
973
mu .Unlock ()
969
974
}
970
975
}
976
+ return clean
971
977
}
972
978
973
979
func (c * clusterClient ) doretrycache (
974
980
ctx context.Context , cc conn , results * redisresults , retries * connretrycache , re * retrycache , mu * sync.Mutex , wg * sync.WaitGroup , attempts int ,
975
981
) {
982
+ clean := true
976
983
if len (re .commands ) != 0 {
977
984
resps := cc .DoMultiCache (ctx , re .commands ... )
978
- c .resultcachefn (ctx , results , retries , mu , cc , re .cIndexes , re .commands , resps .s , attempts )
985
+ clean = c .resultcachefn (ctx , results , retries , mu , cc , re .cIndexes , re .commands , resps .s , attempts )
979
986
resultsp .Put (resps )
980
987
}
981
988
if len (re .cAskings ) != 0 {
982
989
resps := askingMultiCache (cc , ctx , re .cAskings )
983
- c .resultcachefn (ctx , results , retries , mu , cc , re .aIndexes , re .cAskings , resps .s , attempts )
990
+ clean = c .resultcachefn (ctx , results , retries , mu , cc , re .aIndexes , re .cAskings , resps .s , attempts ) && clean
984
991
resultsp .Put (resps )
985
992
}
986
- if ctx . Err () == nil {
993
+ if clean {
987
994
retrycachep .Put (re )
988
995
}
989
996
wg .Done ()
0 commit comments