[Bug] Proxy remoting server shutdown leaves the expired-request timer running

未关闭
#11,456 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@iloveeyjafjalla 已经在做这个了。

开始于 2026年10月20日。

  • #11457 来自 @iloveeyjafjalla —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
java

调研方向

Read RemotingProtocolServer and trace how its constructor creates timerExecutor and how shutdown() handles the remoting executors. The issue reports that linked pull request #11457 addresses the lifecycle bug; inspect its changes and tests to confirm the expected shutdown behavior.

由索引模型根据 Issue 内容生成。

描述

Before Creating the Bug Report
  • I have searched the open issues of this repository and believe that this is not a duplicate.
  • This is a defect in Apache RocketMQ, not a usage question.
  • I can reproduce this on the current develop branch.
RocketMQ Version

develop @ 57c2dc04f78cc7e73e6b8c9436ee0fff0d0f46c3 (the revision this was verified on)

Describe the Bug

RemotingProtocolServer schedules the expired-request cleanup in its constructor:

this.timerExecutor = ThreadUtils.newSingleThreadScheduledExecutor(
    new ThreadFactoryBuilder().setNameFormat("RemotingServerScheduler-%d").build()
);
this.timerExecutor.scheduleAtFixedRate(this::cleanExpireRequest, 100, 100, TimeUnit.MILLISECONDS);

ThreadFactoryBuilder produces non-daemon threads, and shutdown() stops the eight remoting executors but not this one:

this.defaultRemotingServer.shutdown();
this.remotingChannelManager.shutdown();
this.sendMessageExecutor.shutdown();
this.pullMessageExecutor.shutdown();
this.heartbeatExecutor.shutdown();
this.updateOffsetExecutor.shutdown();
this.topicRouteExecutor.shutdown();
this.defaultExecutor.shutdown();
// timerExecutor is never stopped

So a proxy whose remoting server has been shut down keeps a live thread running cleanExpireRequest every 100 ms against the stopped server, and the non-daemon thread keeps the JVM alive after the Spring context has closed instead of letting the process exit.

This is the same shape as #11427: a service created in a constructor is started but not stopped by the owner's shutdown path.

Steps to Reproduce
  1. Start the proxy and stop it again (or close its Spring context in a test).
  2. jstack shows the RemotingServerScheduler-1 thread still alive after RemotingProtocolServer.shutdown() returned, and the process does not exit on its own.
  3. The added test shows the same point without a proxy: with the current code verify(timerExecutor).shutdown() fails with Wanted but not invoked.
What Did You Expect to See?

shutdown() stops the executor it scheduled in the constructor, like the eight remoting executors it already stops, so nothing of the server survives the shutdown.

What Did You See Instead?

The timer thread survives the shutdown, keeps running the 100 ms cleanup task, and keeps the JVM alive.

Additional Context

#10806 reports a different problem in the same class (the cleanup loop swallows exceptions); this one is about the executor's lifecycle.

主要语言
Java
星标
22.7k
派生
12k
平均合并
4 天 20 小时
30 天内合并 PR
11

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/rocketmq 的其他 Issue

查看 apache/rocketmq 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。