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

在这种情况下是不是会出现死锁? #1107

Closed
ye-xiaowei opened this issue Jun 11, 2024 · 3 comments · Fixed by #1108
Closed

在这种情况下是不是会出现死锁? #1107

ye-xiaowei opened this issue Jun 11, 2024 · 3 comments · Fixed by #1108

Comments

@ye-xiaowei
Copy link
Contributor

Your question

在下面这种情况下是不是会出现死锁?

FSMCaller-Disruptor 线程 destroy Replicator,期间还有2个线程在等待 ThreadId 的锁释放

  1. ScheduleThreadPool 线程 heatbeat onTimeout()
  2. Append-Entries-Thread-Send 线程 onRpcReturned()

然后 destroy 完成,先唤醒了 ScheduleThreadPool,但是他不释放锁因为已经 destroyed

} finally {
    // Maybe destroyed in callback
    if (!this.destroyed) {
        this.lock.unlock();
    }
}

所以锁被Schedule线程持有没释放,send 线程就一直卡住了

Environment

  • SOFAJRaft version: 1.3.13
  • JVM version (e.g. java -version): 11
  • OS version (e.g. uname -a): win10
@killme2008
Copy link
Contributor

思考了下,确实有这个可能,这里应该无条件 unlock,不管是否 destroy

@killme2008
Copy link
Contributor

我也忘了当时为啥加这个检查了,可以提个 PR 来修复下。

@ye-xiaowei
Copy link
Contributor Author

嗯嗯

ye-xiaowei pushed a commit to ye-xiaowei/sofa-jraft that referenced this issue Jun 12, 2024
killme2008 pushed a commit that referenced this issue Jun 12, 2024
Co-authored-by: yxw <ye.xiaowei@aliyun.com>
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 a pull request may close this issue.

2 participants