Skip to content

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

@colin-si

Description

@colin-si

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions