Skip to content

Commit f6a8adc

Browse files
committed
fix: remove conn reaper from the pool and uptrace option names
1 parent ae6c6de commit f6a8adc

File tree

14 files changed

+267
-482
lines changed

14 files changed

+267
-482
lines changed

CHANGELOG.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,52 @@
11
# [9.0.0-beta.1](https://github.com/go-redis/redis/compare/v8.11.5...v9.0.0-beta.1) (2022-06-04)
22

3-
43
### Bug Fixes
54

6-
* **#1943:** xInfoConsumer.Idle should be time.Duration instead of int64 ([#2052](https://github.com/go-redis/redis/issues/2052)) ([997ab5e](https://github.com/go-redis/redis/commit/997ab5e7e3ddf53837917013a4babbded73e944f)), closes [#1943](https://github.com/go-redis/redis/issues/1943)
7-
* add XInfoConsumers test ([6f1a1ac](https://github.com/go-redis/redis/commit/6f1a1ac284ea3f683eeb3b06a59969e8424b6376))
8-
* fix tests ([3a722be](https://github.com/go-redis/redis/commit/3a722be81180e4d2a9cf0a29dc9a1ee1421f5859))
9-
* remove test(XInfoConsumer.idle), not a stable return value when tested. ([f5fbb36](https://github.com/go-redis/redis/commit/f5fbb367e7d9dfd7f391fc535a7387002232fa8a))
10-
* update ChannelWithSubscriptions to accept options ([c98c5f0](https://github.com/go-redis/redis/commit/c98c5f0eebf8d254307183c2ce702a48256b718d))
11-
* update COMMAND parser for Redis 7 ([b0bb514](https://github.com/go-redis/redis/commit/b0bb514059249e01ed7328c9094e5b8a439dfb12))
12-
* use redis over ssh channel([#2057](https://github.com/go-redis/redis/issues/2057)) ([#2060](https://github.com/go-redis/redis/issues/2060)) ([3961b95](https://github.com/go-redis/redis/commit/3961b9577f622a3079fe74f8fc8da12ba67a77ff))
13-
5+
- **#1943:** xInfoConsumer.Idle should be time.Duration instead of int64
6+
([#2052](https://github.com/go-redis/redis/issues/2052))
7+
([997ab5e](https://github.com/go-redis/redis/commit/997ab5e7e3ddf53837917013a4babbded73e944f)),
8+
closes [#1943](https://github.com/go-redis/redis/issues/1943)
9+
- add XInfoConsumers test
10+
([6f1a1ac](https://github.com/go-redis/redis/commit/6f1a1ac284ea3f683eeb3b06a59969e8424b6376))
11+
- fix tests
12+
([3a722be](https://github.com/go-redis/redis/commit/3a722be81180e4d2a9cf0a29dc9a1ee1421f5859))
13+
- remove test(XInfoConsumer.idle), not a stable return value when tested.
14+
([f5fbb36](https://github.com/go-redis/redis/commit/f5fbb367e7d9dfd7f391fc535a7387002232fa8a))
15+
- update ChannelWithSubscriptions to accept options
16+
([c98c5f0](https://github.com/go-redis/redis/commit/c98c5f0eebf8d254307183c2ce702a48256b718d))
17+
- update COMMAND parser for Redis 7
18+
([b0bb514](https://github.com/go-redis/redis/commit/b0bb514059249e01ed7328c9094e5b8a439dfb12))
19+
- use redis over ssh channel([#2057](https://github.com/go-redis/redis/issues/2057))
20+
([#2060](https://github.com/go-redis/redis/issues/2060))
21+
([3961b95](https://github.com/go-redis/redis/commit/3961b9577f622a3079fe74f8fc8da12ba67a77ff))
1422

1523
### Features
1624

17-
* add ClientUnpause ([91171f5](https://github.com/go-redis/redis/commit/91171f5e19a261dc4cfbf8706626d461b6ba03e4))
18-
* add NewXPendingResult for unit testing XPending ([#2066](https://github.com/go-redis/redis/issues/2066)) ([b7fd09e](https://github.com/go-redis/redis/commit/b7fd09e59479bc6ed5b3b13c4645a3620fd448a3))
19-
* add WriteArg and Scan net.IP([#2062](https://github.com/go-redis/redis/issues/2062)) ([7d5167e](https://github.com/go-redis/redis/commit/7d5167e8624ac1515e146ed183becb97dadb3d1a))
20-
* **pool:** add check for badConnection ([a8a7665](https://github.com/go-redis/redis/commit/a8a7665ddf8cc657c5226b1826a8ee83dab4b8c1)), closes [#2053](https://github.com/go-redis/redis/issues/2053)
21-
* provide a username and password callback method, so that the plaintext username and password will not be stored in the memory, and the username and password will only be generated once when the CredentialsProvider is called. After the method is executed, the username and password strings on the stack will be released. ([#2097](https://github.com/go-redis/redis/issues/2097)) ([56a3dbc](https://github.com/go-redis/redis/commit/56a3dbc7b656525eb88e0735e239d56e04a23bee))
22-
* upgrade to Redis 7 ([d09c27e](https://github.com/go-redis/redis/commit/d09c27e6046129fd27b1d275e5a13a477bd7f778))
23-
24-
25+
- add ClientUnpause
26+
([91171f5](https://github.com/go-redis/redis/commit/91171f5e19a261dc4cfbf8706626d461b6ba03e4))
27+
- add NewXPendingResult for unit testing XPending
28+
([#2066](https://github.com/go-redis/redis/issues/2066))
29+
([b7fd09e](https://github.com/go-redis/redis/commit/b7fd09e59479bc6ed5b3b13c4645a3620fd448a3))
30+
- add WriteArg and Scan net.IP([#2062](https://github.com/go-redis/redis/issues/2062))
31+
([7d5167e](https://github.com/go-redis/redis/commit/7d5167e8624ac1515e146ed183becb97dadb3d1a))
32+
- **pool:** add check for badConnection
33+
([a8a7665](https://github.com/go-redis/redis/commit/a8a7665ddf8cc657c5226b1826a8ee83dab4b8c1)),
34+
closes [#2053](https://github.com/go-redis/redis/issues/2053)
35+
- provide a username and password callback method, so that the plaintext username and password will
36+
not be stored in the memory, and the username and password will only be generated once when the
37+
CredentialsProvider is called. After the method is executed, the username and password strings on
38+
the stack will be released. ([#2097](https://github.com/go-redis/redis/issues/2097))
39+
([56a3dbc](https://github.com/go-redis/redis/commit/56a3dbc7b656525eb88e0735e239d56e04a23bee))
40+
- upgrade to Redis 7
41+
([d09c27e](https://github.com/go-redis/redis/commit/d09c27e6046129fd27b1d275e5a13a477bd7f778))
2542

2643
## v9 UNRELEASED
2744

2845
- Added support for [RESP3](https://github.com/antirez/RESP3/blob/master/spec.md) protocol.
2946
- Removed `Pipeline.Close` since there is no real need to explicitly manage pipeline resources.
3047
`Pipeline.Discard` is still available if you want to reset commands for some reason.
3148
- Replaced `*redis.Z` with `redis.Z` since it is small enough to be passed as value.
49+
- Renamed `MaxConnAge` to `ConnMaxLifetime`.
50+
- Renamed `IdleTimeout` to `ConnMaxIdleTime`.
51+
- Removed connection reaper in favor of `MaxIdleConns`.
52+
- Removed `WithContext`.

cluster.go

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ type ClusterOptions struct {
7272
PoolFIFO bool
7373

7474
// PoolSize applies per cluster node and not for the whole cluster.
75-
PoolSize int
76-
MinIdleConns int
77-
MaxConnAge time.Duration
78-
PoolTimeout time.Duration
79-
IdleTimeout time.Duration
80-
IdleCheckFrequency time.Duration
75+
PoolSize int
76+
PoolTimeout time.Duration
77+
MinIdleConns int
78+
MaxIdleConns int
79+
ConnMaxIdleTime time.Duration
80+
ConnMaxLifetime time.Duration
8181

8282
TLSConfig *tls.Config
8383
}
@@ -132,8 +132,6 @@ func (opt *ClusterOptions) init() {
132132
}
133133

134134
func (opt *ClusterOptions) clientOptions() *Options {
135-
const disableIdleCheck = -1
136-
137135
return &Options{
138136
Dialer: opt.Dialer,
139137
OnConnect: opt.OnConnect,
@@ -149,13 +147,13 @@ func (opt *ClusterOptions) clientOptions() *Options {
149147
ReadTimeout: opt.ReadTimeout,
150148
WriteTimeout: opt.WriteTimeout,
151149

152-
PoolFIFO: opt.PoolFIFO,
153-
PoolSize: opt.PoolSize,
154-
MinIdleConns: opt.MinIdleConns,
155-
MaxConnAge: opt.MaxConnAge,
156-
PoolTimeout: opt.PoolTimeout,
157-
IdleTimeout: opt.IdleTimeout,
158-
IdleCheckFrequency: disableIdleCheck,
150+
PoolFIFO: opt.PoolFIFO,
151+
PoolSize: opt.PoolSize,
152+
PoolTimeout: opt.PoolTimeout,
153+
MinIdleConns: opt.MinIdleConns,
154+
MaxIdleConns: opt.MaxIdleConns,
155+
ConnMaxIdleTime: opt.ConnMaxIdleTime,
156+
ConnMaxLifetime: opt.ConnMaxLifetime,
159157

160158
TLSConfig: opt.TLSConfig,
161159
// If ClusterSlots is populated, then we probably have an artificial
@@ -725,10 +723,6 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
725723
c.cmdsInfoCache = newCmdsInfoCache(c.cmdsInfo)
726724
c.cmdable = c.Process
727725

728-
if opt.IdleCheckFrequency > 0 {
729-
go c.reaper(opt.IdleCheckFrequency)
730-
}
731-
732726
return c
733727
}
734728

@@ -1049,26 +1043,6 @@ func (c *ClusterClient) loadState(ctx context.Context) (*clusterState, error) {
10491043
return nil, firstErr
10501044
}
10511045

1052-
// reaper closes idle connections to the cluster.
1053-
func (c *ClusterClient) reaper(idleCheckFrequency time.Duration) {
1054-
ticker := time.NewTicker(idleCheckFrequency)
1055-
defer ticker.Stop()
1056-
1057-
for range ticker.C {
1058-
nodes, err := c.nodes.All()
1059-
if err != nil {
1060-
break
1061-
}
1062-
1063-
for _, node := range nodes {
1064-
_, err := node.Client.connPool.(*pool.ConnPool).ReapStaleConns()
1065-
if err != nil {
1066-
internal.Logger.Printf(context.TODO(), "ReapStaleConns failed: %s", err)
1067-
}
1068-
}
1069-
}
1070-
}
1071-
10721046
func (c *ClusterClient) Pipeline() Pipeliner {
10731047
pipe := Pipeline{
10741048
exec: c.processPipeline,

internal/pool/bench_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ func BenchmarkPoolGetPut(b *testing.B) {
3030
for _, bm := range benchmarks {
3131
b.Run(bm.String(), func(b *testing.B) {
3232
connPool := pool.NewConnPool(&pool.Options{
33-
Dialer: dummyDialer,
34-
PoolSize: bm.poolSize,
35-
PoolTimeout: time.Second,
36-
IdleTimeout: time.Hour,
37-
IdleCheckFrequency: time.Hour,
33+
Dialer: dummyDialer,
34+
PoolSize: bm.poolSize,
35+
PoolTimeout: time.Second,
36+
ConnMaxIdleTime: time.Hour,
3837
})
3938

4039
b.ResetTimer()
@@ -74,11 +73,10 @@ func BenchmarkPoolGetRemove(b *testing.B) {
7473
for _, bm := range benchmarks {
7574
b.Run(bm.String(), func(b *testing.B) {
7675
connPool := pool.NewConnPool(&pool.Options{
77-
Dialer: dummyDialer,
78-
PoolSize: bm.poolSize,
79-
PoolTimeout: time.Second,
80-
IdleTimeout: time.Hour,
81-
IdleCheckFrequency: time.Hour,
76+
Dialer: dummyDialer,
77+
PoolSize: bm.poolSize,
78+
PoolTimeout: time.Second,
79+
ConnMaxIdleTime: time.Hour,
8280
})
8381

8482
b.ResetTimer()

internal/pool/conn_check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ func connCheck(conn net.Conn) error {
2727
}
2828

2929
var sysErr error
30-
err = rawConn.Read(func(fd uintptr) bool {
30+
31+
if err := rawConn.Read(func(fd uintptr) bool {
3132
var buf [1]byte
3233
n, err := syscall.Read(int(fd), buf[:])
3334
switch {
@@ -41,8 +42,7 @@ func connCheck(conn net.Conn) error {
4142
sysErr = err
4243
}
4344
return true
44-
})
45-
if err != nil {
45+
}); err != nil {
4646
return err
4747
}
4848

0 commit comments

Comments
 (0)