milvus/internal/datanode/io_pool.go
Jiquan Long 579c50fa1a
Fix io pool goroutine leakage (#19892)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
2022-10-19 18:23:27 +08:00

25 lines
485 B
Go

package datanode
import (
"sync"
"github.com/milvus-io/milvus/internal/util/concurrency"
)
var ioPool *concurrency.Pool
var ioPoolInitOnce sync.Once
func initIOPool() {
capacity := Params.DataNodeCfg.IOConcurrency
if capacity > 32 {
capacity = 32
}
// error only happens with negative expiry duration or with negative pre-alloc size.
ioPool, _ = concurrency.NewPool(capacity)
}
func getOrCreateIOPool() *concurrency.Pool {
ioPoolInitOnce.Do(initIOPool)
return ioPool
}