mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
chore: always retry write timeouts
This commit is contained in:
parent
6725851465
commit
b0231c659e
@ -1,6 +1,6 @@
|
|||||||
# Redis client for Go
|
# Redis client for Go
|
||||||
|
|
||||||

|
[](https://github.com/go-redis/redis/actions)
|
||||||
[](https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc)
|
[](https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc)
|
||||||
[](https://redis.uptrace.dev/)
|
[](https://redis.uptrace.dev/)
|
||||||
[](https://discord.gg/rWtp5Aj)
|
[](https://discord.gg/rWtp5Aj)
|
||||||
|
@ -2,7 +2,6 @@ package redis_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@ -269,7 +268,7 @@ func (p *redisProcess) Close() error {
|
|||||||
if err := p.Client.Ping(ctx).Err(); err != nil {
|
if err := p.Client.Ping(ctx).Err(); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("client is not shutdown")
|
return fmt.Errorf("client %s is not shutdown", p.Options().Addr)
|
||||||
}, 10*time.Second)
|
}, 10*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
return writeCmd(wr, cmd)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
atomic.StoreUint32(&retryTimeout, 1)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +349,8 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if cmd.readTimeout() == nil {
|
if cmd.readTimeout() == nil {
|
||||||
atomic.StoreUint32(&retryTimeout, 1)
|
atomic.StoreUint32(&retryTimeout, 1)
|
||||||
|
} else {
|
||||||
|
atomic.StoreUint32(&retryTimeout, 0)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -137,12 +137,6 @@ var _ = Describe("Redis Ring", func() {
|
|||||||
It("uses 3 shards after setting it to 3 shards", func() {
|
It("uses 3 shards after setting it to 3 shards", func() {
|
||||||
Expect(ring.Len(), 2)
|
Expect(ring.Len(), 2)
|
||||||
|
|
||||||
// Start ringShard3.
|
|
||||||
var err error
|
|
||||||
ringShard3, err = startRedis(ringShard3Port)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
defer ringShard3.Close()
|
|
||||||
|
|
||||||
shardName1 := "ringShardOne"
|
shardName1 := "ringShardOne"
|
||||||
shardAddr1 := ":" + ringShard1Port
|
shardAddr1 := ":" + ringShard1Port
|
||||||
wantShard1 := ring.ShardByName(shardName1)
|
wantShard1 := ring.ShardByName(shardName1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user