caochengxiang opened a new issue, #2101:
URL: https://github.com/apache/dubbo-go/issues/2101
1、线上协程泄漏,通过pprof发现下面两处会有协程泄漏,cluster/router/chain/chain.go;
func (c *RouterChain) AddRouters(routers []router.PriorityRouter) {
newRouters := make([]router.PriorityRouter, 0,
len(c.builtinRouters)+len(routers))
newRouters = append(newRouters, c.builtinRouters...)
newRouters = append(newRouters, routers...)
sortRouter(newRouters)
c.mutex.Lock()
defer c.mutex.Unlock()
c.routers = newRouters
go func() {
c.notify <- struct{}{}
}()
}
// SetInvokers receives updated invokers from registry center. If the times
of notification exceeds countThreshold and
// time interval exceeds timeThreshold since last cache update, then notify
to update the cache.
func (c *RouterChain) SetInvokers(invokers []protocol.Invoker) {
c.mutex.Lock()
c.invokers = invokers
c.mutex.Unlock()
go func() {
c.notify <- struct{}{}
}()
}
2、加_
"git.n.xiaomi.com/open-lib/dubbo-go/cluster/router/conncheck",上述泄漏问题解决,但是会出现新的问题,pprof显示在下面c.mutex.RLock()产生大量协程,这就麻烦了
func (c *RouterChain) copyRouters() []router.PriorityRouter {
c.mutex.RLock()
defer c.mutex.RUnlock()
ret := make([]router.PriorityRouter, 0, len(c.routers))
ret = append(ret, c.routers...)
return ret
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]