mirror of https://github.com/tikv/client-go.git
internal/client: fix recycle idle connection block sending request (#270)
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>
This commit is contained in:
parent
b440ea2f58
commit
31906d4105
|
|
@ -365,9 +365,7 @@ func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.R
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
if atomic.CompareAndSwapUint32(&c.idleNotify, 1, 0) {
|
if atomic.CompareAndSwapUint32(&c.idleNotify, 1, 0) {
|
||||||
c.recycleMu.Lock()
|
go c.recycleIdleConnArray()
|
||||||
c.recycleIdleConnArray()
|
|
||||||
c.recycleMu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TiDB will not send batch commands to TiFlash, to resolve the conflict with Batch Cop Request.
|
// TiDB will not send batch commands to TiFlash, to resolve the conflict with Batch Cop Request.
|
||||||
|
|
|
||||||
|
|
@ -795,6 +795,9 @@ func sendBatchRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RPCClient) recycleIdleConnArray() {
|
func (c *RPCClient) recycleIdleConnArray() {
|
||||||
|
c.recycleMu.Lock()
|
||||||
|
defer c.recycleMu.Unlock()
|
||||||
|
|
||||||
var addrs []string
|
var addrs []string
|
||||||
c.RLock()
|
c.RLock()
|
||||||
for _, conn := range c.conns {
|
for _, conn := range c.conns {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue