internal/client: fix recycle idle connection block sending request (#270)

Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>
This commit is contained in:
tiancaiamao 2021-08-19 23:40:46 +08:00 committed by GitHub
parent b440ea2f58
commit 31906d4105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -365,9 +365,7 @@ func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.R
start := time.Now()
if atomic.CompareAndSwapUint32(&c.idleNotify, 1, 0) {
c.recycleMu.Lock()
c.recycleIdleConnArray()
c.recycleMu.Unlock()
go c.recycleIdleConnArray()
}
// TiDB will not send batch commands to TiFlash, to resolve the conflict with Batch Cop Request.

View File

@ -795,6 +795,9 @@ func sendBatchRequest(
}
func (c *RPCClient) recycleIdleConnArray() {
c.recycleMu.Lock()
defer c.recycleMu.Unlock()
var addrs []string
c.RLock()
for _, conn := range c.conns {