Skip to content

Commit 458982a

Browse files
authored
Merge pull request #1034 from go-redis/fix/pipeline-make-node-as-loading
Mark node as loading in Cluster pipeline read
2 parents e7f7887 + 6238b8d commit 458982a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
all: testdeps
22
go test ./...
33
go test ./... -short -race
4+
go test ./... -run=NONE -bench=.
45
env GOOS=linux GOARCH=386 go test ./...
56
go vet
67
go get github.com/gordonklaus/ineffassign

cluster.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ func (c *ClusterClient) mapCmdsByNode(cmds []Cmder, cmdsMap *cmdsMap) error {
12651265
return err
12661266
}
12671267

1268-
cmdsAreReadOnly := c.cmdsAreReadOnly(cmds)
1268+
cmdsAreReadOnly := c.opt.ReadOnly && c.cmdsAreReadOnly(cmds)
12691269
for _, cmd := range cmds {
12701270
var node *clusterNode
12711271
var err error
@@ -1309,10 +1309,9 @@ func (c *ClusterClient) pipelineProcessCmds(
13091309
return err
13101310
}
13111311

1312-
err = cn.WithReader(c.opt.ReadTimeout, func(rd *proto.Reader) error {
1312+
return cn.WithReader(c.opt.ReadTimeout, func(rd *proto.Reader) error {
13131313
return c.pipelineReadCmds(node, rd, cmds, failedCmds)
13141314
})
1315-
return err
13161315
}
13171316

13181317
func (c *ClusterClient) pipelineReadCmds(
@@ -1329,7 +1328,9 @@ func (c *ClusterClient) pipelineReadCmds(
13291328
continue
13301329
}
13311330

1332-
if internal.IsRedisError(err) {
1331+
if c.opt.ReadOnly && internal.IsLoadingError(err) {
1332+
node.MarkAsLoading()
1333+
} else if internal.IsRedisError(err) {
13331334
continue
13341335
}
13351336

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ require (
44
github.com/onsi/ginkgo v1.8.0
55
github.com/onsi/gomega v1.5.0
66
)
7+
8+
go 1.13

0 commit comments

Comments
 (0)