From 6238b8d4b7cba0be1e2c5e20a7be0e0cfca65679 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sat, 25 May 2019 17:42:01 +0300 Subject: [PATCH] Mark node as loading in Cluster pipeline read --- Makefile | 1 + cluster.go | 9 +++++---- go.mod | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index fa3b4e004..0323b379b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ all: testdeps go test ./... go test ./... -short -race + go test ./... -run=NONE -bench=. env GOOS=linux GOARCH=386 go test ./... go vet go get github.com/gordonklaus/ineffassign diff --git a/cluster.go b/cluster.go index ab2c76f05..68194c8d4 100644 --- a/cluster.go +++ b/cluster.go @@ -1265,7 +1265,7 @@ func (c *ClusterClient) mapCmdsByNode(cmds []Cmder, cmdsMap *cmdsMap) error { return err } - cmdsAreReadOnly := c.cmdsAreReadOnly(cmds) + cmdsAreReadOnly := c.opt.ReadOnly && c.cmdsAreReadOnly(cmds) for _, cmd := range cmds { var node *clusterNode var err error @@ -1309,10 +1309,9 @@ func (c *ClusterClient) pipelineProcessCmds( return err } - err = cn.WithReader(c.opt.ReadTimeout, func(rd *proto.Reader) error { + return cn.WithReader(c.opt.ReadTimeout, func(rd *proto.Reader) error { return c.pipelineReadCmds(node, rd, cmds, failedCmds) }) - return err } func (c *ClusterClient) pipelineReadCmds( @@ -1329,7 +1328,9 @@ func (c *ClusterClient) pipelineReadCmds( continue } - if internal.IsRedisError(err) { + if c.opt.ReadOnly && internal.IsLoadingError(err) { + node.MarkAsLoading() + } else if internal.IsRedisError(err) { continue } diff --git a/go.mod b/go.mod index 57f2bc0db..eb4969dbc 100644 --- a/go.mod +++ b/go.mod @@ -4,3 +4,5 @@ require ( github.com/onsi/ginkgo v1.8.0 github.com/onsi/gomega v1.5.0 ) + +go 1.13