You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "yanglimingcn (via GitHub)" <gi...@apache.org> on 2023/11/07 09:43:23 UTC

Re: [I] Span::CreateClientSpan是否有线程安全问题 (brpc)

yanglimingcn commented on issue #2315:
URL: https://github.com/apache/brpc/issues/2315#issuecomment-1798146290

   > > 上述问题可以通过使用cas进行链表插入来解决,当然brpc的span不止这一处问题,收到请求包后发起异步调用,svr span会被析构。收到异步调用回包后再发起rpc就可能core。done->Run()提前回包后再发起rpc也有类似的问题。 为了解决这个问题我们对svr span加入了引用计数机制。在合适的位置为当前的svr span引用计数+1,析构时-1。算是比较彻底的解决了这个问题。 在这些问题解决前,不建议在生产环境使用brpc的trace。
   > 
   > hello,想请教一下“收到异步调用回包后再发起rpc就可能core”,异步回调中发起rpc时,所在的bthread的thread local的变量中,应该不包含原来那个svr span的指针吧。因为这可能会是一个新的bthread,那么会是什么原因导致的core呢?
   > 
   > 从源代码来看([https://github.com/apache/brpc/blob/master/src/brpc/controller.cpp#L718),创建新的bthread的时候,也没有使用BTHREAD_INHERIT_SPAN标志。brpc这个时候,可能不认为新的rpc请求是老的svr](https://github.com/apache/brpc/blob/master/src/brpc/controller.cpp#L718%EF%BC%89%EF%BC%8C%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84bthread%E7%9A%84%E6%97%B6%E5%80%99%EF%BC%8C%E4%B9%9F%E6%B2%A1%E6%9C%89%E4%BD%BF%E7%94%A8BTHREAD_INHERIT_SPAN%E6%A0%87%E5%BF%97%E3%80%82brpc%E8%BF%99%E4%B8%AA%E6%97%B6%E5%80%99%EF%BC%8C%E5%8F%AF%E8%83%BD%E4%B8%8D%E8%AE%A4%E4%B8%BA%E6%96%B0%E7%9A%84rpc%E8%AF%B7%E6%B1%82%E6%98%AF%E8%80%81%E7%9A%84svr) span的child span了。不知道我理解的是否有问题 @bigolcy
   
   感觉你可以在父bthread里面创建多个span,然后作为argument传递给每个子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: 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