Skip to content

Commit

Permalink
fix: Move init kafka pool into once
Browse files Browse the repository at this point in the history
Introduced by milvus-io#37744

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Nov 18, 2024
1 parent 351463b commit 2761589
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/mq/msgstream/mqwrapper/kafka/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ var (
)

func initPool() {
pool := conc.NewPool[any](
hardware.GetCPUNum(),
conc.WithPreAlloc(false),
conc.WithDisablePurge(false),
conc.WithPreHandler(runtime.LockOSThread), // lock os thread for cgo thread disposal
)

kafkaCPool.Store(pool)
log.Info("init dynamicPool done", zap.Int("size", hardware.GetCPUNum()))
initOnce.Do(func() {
pool := conc.NewPool[any](
hardware.GetCPUNum(),
conc.WithPreAlloc(false),
conc.WithDisablePurge(false),
conc.WithPreHandler(runtime.LockOSThread), // lock os thread for cgo thread disposal
)

kafkaCPool.Store(pool)
log.Info("init dynamicPool done", zap.Int("size", hardware.GetCPUNum()))
})
}

// GetSQPool returns the singleton pool instance for search/query operations.
Expand Down

0 comments on commit 2761589

Please sign in to comment.