Skip to content

Commit

Permalink
Merge pull request redis#936 from go-redis/fix/retry-cluster-pipeline…
Browse files Browse the repository at this point in the history
…-read-cmds

Retry cluster pipeline read commands
  • Loading branch information
vmihailenco authored Dec 17, 2018
2 parents 6ff343b + 10edc85 commit 7f89fba
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1314,14 +1314,15 @@ func (c *ClusterClient) pipelineProcessCmds(
}

err = cn.WithReader(c.opt.ReadTimeout, func(rd *proto.Reader) error {
return c.pipelineReadCmds(rd, cmds, failedCmds)
return c.pipelineReadCmds(node, rd, cmds, failedCmds)
})
return err
}

func (c *ClusterClient) pipelineReadCmds(
rd *proto.Reader, cmds []Cmder, failedCmds *cmdsMap,
node *clusterNode, rd *proto.Reader, cmds []Cmder, failedCmds *cmdsMap,
) error {
var firstErr error
for _, cmd := range cmds {
err := cmd.readReply(rd)
if err == nil {
Expand All @@ -1336,9 +1337,14 @@ func (c *ClusterClient) pipelineReadCmds(
continue
}

return err
failedCmds.mu.Lock()
failedCmds.m[node] = append(failedCmds.m[node], cmd)
failedCmds.mu.Unlock()
if firstErr == nil {
firstErr = err
}
}
return nil
return firstErr
}

func (c *ClusterClient) checkMovedErr(
Expand Down

0 comments on commit 7f89fba

Please sign in to comment.