You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2020/09/08 04:19:01 UTC

[GitHub] [incubator-brpc] dyinnz opened a new issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

dyinnz opened a new issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229


   **Describe the bug (描述bug)**
   **To Reproduce (复现方法)**
   
   We may lock a std::recursive_mutex server times during a call. A deadlock occurs if bthread switched:
   
   1. First, a bthread owns a std::recursive_mutex, and does something.
   2. Then, this bthread switches to another (real) thread, and tries to lock again.
   3. OK, here is a deadlock or a lock leaking. The std::recursive_mutex is hold by the old real thread, but the new thread would hang here if try to lock again.
   
   **Expected behavior (期望行为)**
   i thought that brpc could not support std::recursive_mutex after reading code and implementation. I ask whether and when this pr https://github.com/apache/incubator-brpc/pull/749 will be merged ? So we could replace std::recursive_mutex in our project.
   
   
   **Versions (各种版本)**
   OS: linux 4.14
   Compiler: gcc 10.2.0, c++2a
   brpc: n/a
   protobuf: n/a
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
gydong commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-688637622


   在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] datatechboost edited a comment on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
datatechboost edited a comment on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-891492822


   > > > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   > > 
   > > 
   > > 你好,可以详细解释一下这个的原因吗? 比如我们加了一个bthread_mutex锁然后发起rpc,rpc正常返回(或超时返回)后我们继续执行,为什么是不行的? ps: 我使用时看起来那个rpc一直(按照早超时了)不返回,不知道是什么原因。
   > 
   > 锁内rpc容易把所有worker都锁住,这样持锁的rpc将没有worker来执行导致锁永远无法释放
   
   感谢你的回复,首先说明一下设计上锁内rpc确实并发度不好,进一步咨询是想理解的更深入。
   使用bthread_mutex的话,worker是否不会被阻塞,如果不会阻塞是否有其它原因,我猜测是因为可运行任务的抢占有关,但是我自己没有不理顺。


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] luobuda commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
luobuda commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-890667319


   锁内发rpc不管在哪都不该这么用吧
   


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] dyinnz commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
dyinnz commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-688659081


   > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   
   这里说的'锁内RPC'是指什么意思?我上面说的场景中,是 RPC 的被调用端,部分操作需要加锁,应该是 RPC内部用锁?
   BTW,如果只是普通的 mutex,这里的行为应该是这个 bthread/pthread 被阻塞,只要 pthread worker 没有用完,这里应该不至于死锁吧?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] datatechboost edited a comment on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
datatechboost edited a comment on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-891492822


   > > > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   > > 
   > > 
   > > 你好,可以详细解释一下这个的原因吗? 比如我们加了一个bthread_mutex锁然后发起rpc,rpc正常返回(或超时返回)后我们继续执行,为什么是不行的? ps: 我使用时看起来那个rpc一直(按照早超时了)不返回,不知道是什么原因。
   > 
   > 锁内rpc容易把所有worker都锁住,这样持锁的rpc将没有worker来执行导致锁永远无法释放
   
   感谢你的回复,首先说明一下设计上锁内rpc确实并发度不好,进一步咨询是想理解的更深入。
   使用bthread_mutex的话,worker是否不会被阻塞,如果不会阻塞是否有其它原因,我猜测是因为可运行任务的抢占有关,但是我自己没有理顺。


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] datatechboost edited a comment on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
datatechboost edited a comment on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-890528631


   > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   
   你好,可以详细解释一下这个的原因吗? 比如我们加了一个bthread_mutex锁然后发起rpc,rpc正常返回(或超时返回)后我们继续执行,为什么是不行的?    ps: 我使用时看起来那个rpc一直(按照早超时了)不返回,不知道是什么原因。


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
gydong commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-688687371


   用STL中的mutex,不会导致bthread被切换到另一个系统线程中,因为系统线程会被阻塞,除非这个过程中调用了一些特定的阻塞函数(如bthread_sleep和butex_wait等等)或者做了同步rpc请求等等


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] datatechboost commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
datatechboost commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-890528631


   > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   
   你好,可以详细解释一下这个的原因吗? 比如我们加了一个bthread_mutex锁然后发起rpc,rpc正常返回(或超时返回)后我们继续执行,为什么是不行的? 


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] cdjingit commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
cdjingit commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-890760365


   > > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   > 
   > 你好,可以详细解释一下这个的原因吗? 比如我们加了一个bthread_mutex锁然后发起rpc,rpc正常返回(或超时返回)后我们继续执行,为什么是不行的? ps: 我使用时看起来那个rpc一直(按照早超时了)不返回,不知道是什么原因。
   
   锁内rpc容易把所有worker都锁住,这样持锁的rpc将没有worker来执行导致锁永远无法释放


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] datatechboost commented on issue #1229: Deadlock on std::recursive_mutex if bthread switched to another (real) thread while serving a RPC call

Posted by GitBox <gi...@apache.org>.
datatechboost commented on issue #1229:
URL: https://github.com/apache/incubator-brpc/issues/1229#issuecomment-891492822


   > > > 在brpc框架下,锁内RPC属于未定义行为,不管换成什么锁,问题还是一样
   > > 
   > > 
   > > 你好,可以详细解释一下这个的原因吗? 比如我们加了一个bthread_mutex锁然后发起rpc,rpc正常返回(或超时返回)后我们继续执行,为什么是不行的? ps: 我使用时看起来那个rpc一直(按照早超时了)不返回,不知道是什么原因。
   > 
   > 锁内rpc容易把所有worker都锁住,这样持锁的rpc将没有worker来执行导致锁永远无法释放
   
   感谢你的回复,首先说明一下设计上锁内rpc确实并发度不好,想理解的更深入一层。
   使用bthread_mutex的话,worker是否不会被阻塞,如果不会阻塞是否有其它原因,我猜测是因为可运行任务的抢占有关,但是我自己没有不理顺。


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org