zgaze commented on issue #2313: URL: https://github.com/apache/brpc/issues/2313#issuecomment-1631772126
> 我理解,(worker上)pthread锁内挂起bthread(rpc、bthread_usleep、butex等)的逻辑是有问题的,会很容易导致死锁。例如这个场景下: > > 一个worker线程执行bthread的时候加了pthread锁,然后挂起了。在该bthread释放pthread锁之前,该worker线程继续调度其他bthread(逻辑与前面的bthread一样),加了同一把pthread锁。在同一个pthread中连续加两次会死锁,逐渐地其他worker也加这把pthread锁,最后所有worker就阻塞在pthread锁上了。 那么,总结来说。bthread+pthread线程池是有风险的,只要里面使用了bthread就会导致死锁。 我能想到的解决方案有: 1、pthread内部只使用pthread,不使用bthread,brpc client也使用pthread的。 那么目前:要做异步的pthread的使用DynamicPartitionChannel 的client,能否**从bthread快速切换到pthread** ? 2、处理请求不使用bthread,而使用pthread。比如:-usercode_in_pthread。 因为等待tf结果算是一个同步操作,那么可能需要比较大的线程池。 rpc的回调能否不使用bthread? 如果有其他更好的解决方案,欢迎补充。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
