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

kvstore/cache_kv.go中很多方法没有使用defer的方式来释放锁,可能会有死锁的风险 #1436

Open
colin-si opened this issue Dec 13, 2023 · 0 comments

Comments

@colin-si
Copy link

Describe the bug
kvstore/cache_kv.go中很多方法没有使用defer的方式来释放锁,可能会有死锁的风险

To Reproduce
如下代码可能 在获取锁之后若有执行异常则会崩掉,则全局锁则无法释放,造成死锁。
image
https://github.com/apache/servicecomb-service-center/blob/ce7afe04f5bcad594bede6204a37443bfa9c0a00/datasource/etcd/state/kvstore/cache_kv.go#L45C6-L45C6






Expected behavior
此处预期获取锁之后的执行逻辑无异常,及时把锁释放掉。
为了增强可靠性,可以通过defer的方式来释放锁。

Platform And Runtime (please complete the following information):

Platform

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Runtime

  • Version [e.g. Go 1.11]

Additional context
Add any other context about the problem here.

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