Fix Cgo lock os thread failed (#19148)

Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>

Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>
This commit is contained in:
Xiaofan 2022-09-13 10:16:30 +08:00 committed by GitHub
parent 5b077ae980
commit ec48e2405a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,15 +240,20 @@ func (node *QueryNode) Init() error {
return
}
// ensure every cgopool go routine is locked with a OS thread
// so openmp in knowhere won't create too much request
sig := make(chan struct{})
wg := sync.WaitGroup{}
wg.Add(cpuNum)
for i := 0; i < cpuNum; i++ {
node.cgoPool.Submit(func() (interface{}, error) {
runtime.LockOSThread()
wg.Done()
<-sig
return nil, nil
})
}
wg.Wait()
close(sig)
node.metaReplica = newCollectionReplica(node.cgoPool)