Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bvar 的全局 VarMap 锁为 pthread mutex, 可能引发死锁 #2888

Open
r-value opened this issue Feb 6, 2025 · 0 comments
Open

bvar 的全局 VarMap 锁为 pthread mutex, 可能引发死锁 #2888

r-value opened this issue Feb 6, 2025 · 0 comments

Comments

@r-value
Copy link

r-value commented Feb 6, 2025

Describe the bug (描述bug)
在从 /brpc_metrics 采集 metric 的时候, 请求由 bthread 执行, 而此时会为了锁住全局 VarMap 获取一个 pthread mutex, 当有一个用户定义的 metric 中出现了 bthread yield, 则会引起死锁.

To Reproduce (复现方法)
使用 PassiveStatus, 然后在这个 metric 的计算函数中引入一个 bthread::Mutex 的获取, 即会引起死锁. 其他的会产生 bthread yield 的同步原语均可引起同样行为.

Expected behavior (期望行为)
个人认为在这里出现 pthread mutex 是反直觉的, 尤其是在文档强调不要令 pthread mutex 和 bthread mutex 混用的情况下. 希望可以:

  • 将这个锁改为 bthread mutex, 或者
  • 在文档中做补充, 强调不要在自定义 metric 中 yield bthread

Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots (更多上下文/截图)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant