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

Support detection of mutex deadlock caused by double lock #2765

Merged
merged 2 commits into from
Oct 13, 2024

Conversation

chenBright
Copy link
Contributor

@chenBright chenBright commented Sep 16, 2024

What problem does this PR solve?

Issue Number:

Problem Summary:

What is changed and the side effects?

Changed:

加锁成功记录下拥有锁的bthread/pthread id,如果在同一个bthread/pthread,就可以检测到在同一个bthread/pthread中重复加锁。

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@chenBright chenBright changed the title Support detection of bthread mutex and FastMutex caused by double lock Support detection of bthread mutex and FastMutex deadlock caused by double lock Sep 16, 2024
@wwbmmm
Copy link
Contributor

wwbmmm commented Sep 19, 2024

这个是否会影响性能?

@chenBright chenBright force-pushed the bthread_deadlock_detection branch 7 times, most recently from da030ca to b01486b Compare September 22, 2024 03:59
@chenBright
Copy link
Contributor Author

这个是否会影响性能?

之前的实现不会影响性能,但是没用原子变量没法保证正确性。现在用原子变量实现后会导致性能退化,MutexTest.performance测试发现锁的平均运行时间慢了50%左右,所以该功能只作为debug手段,默认关闭,只有编译bRPC库时定义了DEBUG_MUTEX宏才会开启该功能。

@wwbmmm
Copy link
Contributor

wwbmmm commented Sep 22, 2024

LGTM

@wwbmmm
Copy link
Contributor

wwbmmm commented Oct 7, 2024

@chenBright 这个PR和主干冲突了

@chenBright chenBright force-pushed the bthread_deadlock_detection branch 5 times, most recently from a3542fa to 38cbe65 Compare October 13, 2024 09:12
@chenBright
Copy link
Contributor Author

  1. rebase解决冲突。
  2. 支持pthread mutex。

@chenBright chenBright changed the title Support detection of bthread mutex and FastMutex deadlock caused by double lock Support detection of mutex deadlock caused by double lock Oct 13, 2024
@wwbmmm wwbmmm merged commit f4e00ac into apache:master Oct 13, 2024
20 checks passed
@chenBright chenBright deleted the bthread_deadlock_detection branch October 13, 2024 13:29
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

Successfully merging this pull request may close these issues.

2 participants