Stop execution pool in rpc handler (#1005)

* Stop execution pool in rpc handler

All execution pools need to be closed properly. This fixes a potential goroutine leak caused by metric goutine created by each execution pool.

* Cancel only once
This commit is contained in:
Jerry 2023-09-15 13:06:47 -07:00 committed by GitHub
parent 5fcd45eaf3
commit fbb9020bec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -22,6 +22,7 @@ type SafePool struct {
processed atomic.Int64 // keeps count of total processed requests
close chan struct{}
closeOnce sync.Once
// Skip sending task to execution pool
fastPath bool
@ -103,7 +104,9 @@ func (s *SafePool) Size() int {
}
func (s *SafePool) Stop() {
s.closeOnce.Do(func() {
close(s.close)
})
if s.executionPool.Load() != nil {
s.executionPool.Load().Stop()

View file

@ -302,6 +302,7 @@ func (h *handler) close(err error, inflightReq *requestOp) {
h.callWG.Wait()
h.cancelRoot()
h.cancelServerSubscriptions(err)
h.executionPool.Stop()
}
// addRequestOp registers a request operation.