Closed luky116 closed 1 month ago
此次更改增强了 BaseCmd::Execute
方法的控制流,确保在未设置 kCmdFlagsExclusive
标志时,始终调用 UnLockShared
方法。通过引入 DEFER
块,确保共享锁在方法退出时被正确释放,从而提高了资源管理的健壮性。这一改动有效防止了潜在的死锁和资源泄漏问题。
文件 | 修改摘要 |
---|---|
src/base_cmd.cc | 引入 DEFER 块以确保在没有 kCmdFlagsExclusive 标志时,始终释放共享锁,增强方法的可靠性。 |
Objective | Addressed | Explanation |
---|---|---|
使用 TCL 跑 flushdb 命令会卡死 (#384) | ✅ |
🐇
在代码间跳跃,锁的解放,
共享的资源,不再尴尬停滞,
每次退出,确保无忧无虑,
兔子欢唱,庆祝这新改进!
🎉
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
fix #384
Reason analysis: If the parameters of cmd are unreasonable, the DoInitial method will return false. The original logic exits directly here. If the shared lock is not released, other processes that want to obtain exclusive locks will remain stuck because they cannot obtain the lock.
原因分析:如果 cmd 的参数不合理,DoInitial 方法会返回 false。原逻辑在这里直接就退出了,没有释放共享锁,会导致其他要获取独享锁的流程因为无法获取锁一直卡主
Summary by CodeRabbit