Skip to content

Commit b0231c6

Browse files
committed
chore: always retry write timeouts
1 parent 6725851 commit b0231c6

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Redis client for Go
22

3-
![build workflow](https://github.com/go-redis/redis/actions/workflows/build.yml/badge.svg)
3+
[![build workflow](https://github.com/go-redis/redis/actions/workflows/build.yml/badge.svg)](https://github.com/go-redis/redis/actions)
44
[![PkgGoDev](https://pkg.go.dev/badge/github.com/go-redis/redis/v8)](https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc)
55
[![Documentation](https://img.shields.io/badge/redis-documentation-informational)](https://redis.uptrace.dev/)
66
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)

main_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package redis_test
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"net"
87
"os"
@@ -269,7 +268,7 @@ func (p *redisProcess) Close() error {
269268
if err := p.Client.Ping(ctx).Err(); err != nil {
270269
return nil
271270
}
272-
return errors.New("client is not shutdown")
271+
return fmt.Errorf("client %s is not shutdown", p.Options().Addr)
273272
}, 10*time.Second)
274273
if err != nil {
275274
return err

redis.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,16 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
341341
return writeCmd(wr, cmd)
342342
})
343343
if err != nil {
344+
atomic.StoreUint32(&retryTimeout, 1)
344345
return err
345346
}
346347

347348
err = cn.WithReader(ctx, c.cmdTimeout(cmd), cmd.readReply)
348349
if err != nil {
349350
if cmd.readTimeout() == nil {
350351
atomic.StoreUint32(&retryTimeout, 1)
352+
} else {
353+
atomic.StoreUint32(&retryTimeout, 0)
351354
}
352355
return err
353356
}

ring_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,6 @@ var _ = Describe("Redis Ring", func() {
137137
It("uses 3 shards after setting it to 3 shards", func() {
138138
Expect(ring.Len(), 2)
139139

140-
// Start ringShard3.
141-
var err error
142-
ringShard3, err = startRedis(ringShard3Port)
143-
Expect(err).NotTo(HaveOccurred())
144-
defer ringShard3.Close()
145-
146140
shardName1 := "ringShardOne"
147141
shardAddr1 := ":" + ringShard1Port
148142
wantShard1 := ring.ShardByName(shardName1)

0 commit comments

Comments
 (0)