diff --git a/ring.go b/ring.go index 26b06b62..4b20e7a9 100644 --- a/ring.go +++ b/ring.go @@ -298,6 +298,9 @@ func (pipe *RingPipeline) Exec() (cmds []Cmder, retErr error) { name := pipe.ring.hash.Get(hashKey(cmd.clusterKey())) if name == "" { cmd.setErr(errRingShardsDown) + if retErr == nil { + retErr = errRingShardsDown + } continue } cmdsMap[name] = append(cmdsMap[name], cmd) diff --git a/ring_test.go b/ring_test.go index 117a9731..5b52b320 100644 --- a/ring_test.go +++ b/ring_test.go @@ -94,6 +94,15 @@ var _ = Describe("Redis ring", func() { }) Describe("pipelining", func() { + It("returns an error when all shards are down", func() { + ring := redis.NewRing(&redis.RingOptions{}) + _, err := ring.Pipelined(func(pipe *redis.RingPipeline) error { + pipe.Ping() + return nil + }) + Expect(err).To(MatchError("redis: all ring shards are down")) + }) + It("uses both shards", func() { pipe := ring.Pipeline() for i := 0; i < 100; i++ {