mirror of https://github.com/go-redis/redis.git
chore: always retry write timeouts
This commit is contained in:
parent
6725851465
commit
b0231c659e
|
@ -1,6 +1,6 @@
|
|||
# Redis client for Go
|
||||
|
||||
![build workflow](https://github.com/go-redis/redis/actions/workflows/build.yml/badge.svg)
|
||||
[![build workflow](https://github.com/go-redis/redis/actions/workflows/build.yml/badge.svg)](https://github.com/go-redis/redis/actions)
|
||||
[![PkgGoDev](https://pkg.go.dev/badge/github.com/go-redis/redis/v8)](https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc)
|
||||
[![Documentation](https://img.shields.io/badge/redis-documentation-informational)](https://redis.uptrace.dev/)
|
||||
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)
|
||||
|
|
|
@ -2,7 +2,6 @@ package redis_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
|
@ -269,7 +268,7 @@ func (p *redisProcess) Close() error {
|
|||
if err := p.Client.Ping(ctx).Err(); err != nil {
|
||||
return nil
|
||||
}
|
||||
return errors.New("client is not shutdown")
|
||||
return fmt.Errorf("client %s is not shutdown", p.Options().Addr)
|
||||
}, 10*time.Second)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
3
redis.go
3
redis.go
|
@ -341,6 +341,7 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
|
|||
return writeCmd(wr, cmd)
|
||||
})
|
||||
if err != nil {
|
||||
atomic.StoreUint32(&retryTimeout, 1)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -348,6 +349,8 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
|
|||
if err != nil {
|
||||
if cmd.readTimeout() == nil {
|
||||
atomic.StoreUint32(&retryTimeout, 1)
|
||||
} else {
|
||||
atomic.StoreUint32(&retryTimeout, 0)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -137,12 +137,6 @@ var _ = Describe("Redis Ring", func() {
|
|||
It("uses 3 shards after setting it to 3 shards", func() {
|
||||
Expect(ring.Len(), 2)
|
||||
|
||||
// Start ringShard3.
|
||||
var err error
|
||||
ringShard3, err = startRedis(ringShard3Port)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defer ringShard3.Close()
|
||||
|
||||
shardName1 := "ringShardOne"
|
||||
shardAddr1 := ":" + ringShard1Port
|
||||
wantShard1 := ring.ShardByName(shardName1)
|
||||
|
|
Loading…
Reference in New Issue