mirror of https://github.com/go-redis/redis.git
FIX: data race warning in sentinel client since the newConnPool would spawn the new
goroutine and use the onFailover at the same time.
This commit is contained in:
parent
5aedb90a65
commit
956f43e3f9
|
@ -177,11 +177,13 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
|
||||||
opt.init()
|
opt.init()
|
||||||
|
|
||||||
connPool := newConnPool(opt)
|
connPool := newConnPool(opt)
|
||||||
|
failover.mu.Lock()
|
||||||
failover.onFailover = func(ctx context.Context, addr string) {
|
failover.onFailover = func(ctx context.Context, addr string) {
|
||||||
_ = connPool.Filter(func(cn *pool.Conn) bool {
|
_ = connPool.Filter(func(cn *pool.Conn) bool {
|
||||||
return cn.RemoteAddr().String() != addr
|
return cn.RemoteAddr().String() != addr
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
failover.mu.Unlock()
|
||||||
|
|
||||||
c := Client{
|
c := Client{
|
||||||
baseClient: newBaseClient(opt, connPool),
|
baseClient: newBaseClient(opt, connPool),
|
||||||
|
|
Loading…
Reference in New Issue