Skip to content

Commit c1c6f8e

Browse files
authored
Merge branch 'master' into master
2 parents 81d68e2 + a402c55 commit c1c6f8e

File tree

11 files changed

+306
-24
lines changed

11 files changed

+306
-24
lines changed

.github/actions/run-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
2626
# Mapping of redis version to redis testing containers
2727
declare -A redis_version_mapping=(
28-
["8.0-M03"]="8.0-M04-pre"
28+
["8.0-M05"]="8.0-M05-pre"
2929
["7.4.2"]="rs-7.4.0-v2"
3030
["7.2.7"]="rs-7.2.0-v14"
3131
)

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
redis-version:
21-
- "8.0-M03" # 8.0 milestone 4
21+
- "8.0-M05" # 8.0 milestone 5
2222
- "7.4.2" # should use redis stack 7.4
2323
go-version:
2424
- "1.23.x"
@@ -43,7 +43,7 @@ jobs:
4343
4444
# Mapping of redis version to redis testing containers
4545
declare -A redis_version_mapping=(
46-
["8.0-M03"]="8.0-M04-pre"
46+
["8.0-M05"]="8.0-M05-pre"
4747
["7.4.2"]="rs-7.4.0-v2"
4848
)
4949
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
@@ -72,7 +72,7 @@ jobs:
7272
fail-fast: false
7373
matrix:
7474
redis-version:
75-
- "8.0-M03" # 8.0 milestone 4
75+
- "8.0-M05" # 8.0 milestone 5
7676
- "7.4.2" # should use redis stack 7.4
7777
- "7.2.7" # should redis stack 7.2
7878
go-version:

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: golangci-lint
24-
uses: golangci/[email protected].0
24+
uses: golangci/[email protected].1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.ci:
1717
(cd "$${dir}" && \
1818
go mod tidy -compat=1.18 && \
1919
go vet && \
20-
go test -coverprofile=coverage.txt -covermode=atomic ./... -race); \
20+
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race); \
2121
done
2222
cd internal/customvet && go build .
2323
go vet -vettool ./internal/customvet/customvet

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
services:
44
redis:
55
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
6+
platform: linux/amd64
67
container_name: redis-standalone
78
environment:
89
- TLS_ENABLED=yes
@@ -23,6 +24,7 @@ services:
2324

2425
osscluster:
2526
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
27+
platform: linux/amd64
2628
container_name: redis-osscluster
2729
environment:
2830
- NODES=6
@@ -39,6 +41,7 @@ services:
3941

4042
sentinel-cluster:
4143
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
44+
platform: linux/amd64
4245
container_name: redis-sentinel-cluster
4346
network_mode: "host"
4447
environment:
@@ -58,6 +61,7 @@ services:
5861

5962
sentinel:
6063
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
64+
platform: linux/amd64
6165
container_name: redis-sentinel
6266
depends_on:
6367
- sentinel-cluster
@@ -81,6 +85,7 @@ services:
8185

8286
ring-cluster:
8387
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
88+
platform: linux/amd64
8489
container_name: redis-ring-cluster
8590
environment:
8691
- NODES=3

error.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func shouldRetry(err error, retryTimeout bool) bool {
5353
return true
5454
case nil, context.Canceled, context.DeadlineExceeded:
5555
return false
56+
case pool.ErrPoolTimeout:
57+
// connection pool timeout, increase retries. #3289
58+
return true
5659
}
5760

5861
if v, ok := err.(timeoutError); ok {

error_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package redis_test
2+
3+
import (
4+
"context"
5+
"errors"
6+
"io"
7+
8+
. "github.com/bsm/ginkgo/v2"
9+
. "github.com/bsm/gomega"
10+
"github.com/redis/go-redis/v9"
11+
)
12+
13+
type testTimeout struct {
14+
timeout bool
15+
}
16+
17+
func (t testTimeout) Timeout() bool {
18+
return t.timeout
19+
}
20+
21+
func (t testTimeout) Error() string {
22+
return "test timeout"
23+
}
24+
25+
var _ = Describe("error", func() {
26+
BeforeEach(func() {
27+
28+
})
29+
30+
AfterEach(func() {
31+
32+
})
33+
34+
It("should retry", func() {
35+
data := map[error]bool{
36+
io.EOF: true,
37+
io.ErrUnexpectedEOF: true,
38+
nil: false,
39+
context.Canceled: false,
40+
context.DeadlineExceeded: false,
41+
redis.ErrPoolTimeout: true,
42+
errors.New("ERR max number of clients reached"): true,
43+
errors.New("LOADING Redis is loading the dataset in memory"): true,
44+
errors.New("READONLY You can't write against a read only replica"): true,
45+
errors.New("CLUSTERDOWN The cluster is down"): true,
46+
errors.New("TRYAGAIN Command cannot be processed, please try again"): true,
47+
errors.New("other"): false,
48+
}
49+
50+
for err, expected := range data {
51+
Expect(redis.ShouldRetry(err, false)).To(Equal(expected))
52+
Expect(redis.ShouldRetry(err, true)).To(Equal(expected))
53+
}
54+
})
55+
56+
It("should retry timeout", func() {
57+
t1 := testTimeout{timeout: true}
58+
Expect(redis.ShouldRetry(t1, true)).To(Equal(true))
59+
Expect(redis.ShouldRetry(t1, false)).To(Equal(false))
60+
61+
t2 := testTimeout{timeout: false}
62+
Expect(redis.ShouldRetry(t2, true)).To(Equal(true))
63+
Expect(redis.ShouldRetry(t2, false)).To(Equal(true))
64+
})
65+
})

export_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/redis/go-redis/v9/internal/pool"
1212
)
1313

14+
var ErrPoolTimeout = pool.ErrPoolTimeout
15+
1416
func (c *baseClient) Pool() pool.Pooler {
1517
return c.connPool
1618
}
@@ -102,3 +104,7 @@ func (c *Ring) ShardByName(name string) *ringShard {
102104
func (c *ModuleLoadexConfig) ToArgs() []interface{} {
103105
return c.toArgs()
104106
}
107+
108+
func ShouldRetry(err error, retryTimeout bool) bool {
109+
return shouldRetry(err, retryTimeout)
110+
}

extra/rediscmd/rediscmd.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func CmdString(cmd redis.Cmder) string {
1717
}
1818

1919
func CmdsString(cmds []redis.Cmder) (string, string) {
20-
const numCmdLimit = 100
2120
const numNameLimit = 10
2221

2322
seen := make(map[string]struct{}, numNameLimit)
@@ -26,10 +25,6 @@ func CmdsString(cmds []redis.Cmder) (string, string) {
2625
b := make([]byte, 0, 32*len(cmds))
2726

2827
for i, cmd := range cmds {
29-
if i > numCmdLimit {
30-
break
31-
}
32-
3328
if i > 0 {
3429
b = append(b, '\n')
3530
}
@@ -51,12 +46,7 @@ func CmdsString(cmds []redis.Cmder) (string, string) {
5146
}
5247

5348
func AppendCmd(b []byte, cmd redis.Cmder) []byte {
54-
const numArgLimit = 32
55-
5649
for i, arg := range cmd.Args() {
57-
if i > numArgLimit {
58-
break
59-
}
6050
if i > 0 {
6151
b = append(b, ' ')
6252
}
@@ -72,20 +62,12 @@ func AppendCmd(b []byte, cmd redis.Cmder) []byte {
7262
}
7363

7464
func appendArg(b []byte, v interface{}) []byte {
75-
const argLenLimit = 64
76-
7765
switch v := v.(type) {
7866
case nil:
7967
return append(b, "<nil>"...)
8068
case string:
81-
if len(v) > argLenLimit {
82-
v = v[:argLenLimit]
83-
}
8469
return appendUTF8String(b, Bytes(v))
8570
case []byte:
86-
if len(v) > argLenLimit {
87-
v = v[:argLenLimit]
88-
}
8971
return appendUTF8String(b, v)
9072
case int:
9173
return strconv.AppendInt(b, int64(v), 10)

0 commit comments

Comments
 (0)