Skip to content

Commit

Permalink
fix: Move init kafka pool into once (#37786)
Browse files Browse the repository at this point in the history
Introduced by #37744

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Nov 18, 2024
1 parent 351463b commit 97b7ebb
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 97b7ebb

Please sign in to comment.