Skip to content

fix: never lose a new-log wakeup dispatch in LogManagerImpl#1272

Closed
mayu-x wants to merge 1 commit into
sofastack:masterfrom
mayu-x:master
Closed

fix: never lose a new-log wakeup dispatch in LogManagerImpl#1272
mayu-x wants to merge 1 commit into
sofastack:masterfrom
mayu-x:master

Conversation

@mayu-x

@mayu-x mayu-x commented Jun 16, 2026

Copy link
Copy Markdown

Motivation:

当 JRAFT_GROUP_DEFAULT_EXECUTOR 线程池繁忙时,LogManagerImpl#wakeupAllWaiter 方法调用 ThreadPoolsFactory.runInThread 可能抛出 RejectedExecutionException 异常,这将导致waiter对象无法再被放回waitMap中,Replicator同步过程会永远被卡在 wakeupAllWaiter 方法开头的 if (this.waitMap.isEmpty()) 处,无法自愈。

Screenshot 2026-06-16 at 15 54 59

问题背景详见:#1271

Modification:

在 wakeupAllWaiter 方法内捕获 ThreadPoolsFactory.runInThread 可能抛出的 RejectedExecutionException 异常,并使用独立线程池(采用LinkedBlockingQueue做workQueue,不会抛RejectedExecutionException)兜底重试。

Result:

Fixes #1271.

If there is no issue then describe the changes introduced by this PR.

@sofastack-cla

sofastack-cla Bot commented Jun 16, 2026

Copy link
Copy Markdown

Hi @mayu-x, welcome to SOFAStack community, Please sign Contributor License Agreement!

After you signed CLA, we will automatically sync the status of this pull request in 3 minutes.

@fengjiachun

Copy link
Copy Markdown
Contributor

这个问题其实不需要修改代码,ThreadPoolsFactory#registerThreadPool 提供注册自定义 executor,你自己注册合适的就好

@killme2008

Copy link
Copy Markdown
Contributor

@mayu-x
Hello,理解你的沮丧,尤其在故障排查的时候。

这个问题我们并非不重视,而是讨论过几次,没有特别好的方案——在可靠性和设计良好之间。

所以我们在 1.4.1 提供了 Closure#getExecutor 接口让用户的回调自行设置线程池,并且隔离了内部和默认 user closure 全局的线程池

default ExecutorService getExecutor() {

可以参考 #1237

不过用户指南的最佳实践确实 oudated 很久了,考虑到我们几个都是业余在维护此项目,还请谅解。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

当 JRAFT_GROUP_DEFAULT_EXECUTOR 线程池跑满可能导致Replicator同步永久中断

3 participants