[Bug] DefaultReceiptHandleManager leaves its renew and return-handle thread pools running after shutdown

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

维护者通常 1 天内回复

@iloveeyjafjalla 已经在做这个了。

开始于 2026年10月13日。

  • #11394 来自 @iloveeyjafjalla —— 未关闭
  • #11421 来自 @Asthenia0412 —— 未关闭

评估

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

调研方向

Start in DefaultReceiptHandleManager: read its constructor, where renewalWorkerService and returnHandleGroupWorkerService are created, and its shutdown() method, which currently only stops scheduledExecutorService and calls clearAllHandle(). Confirm that nothing shuts the two pools down. Done means both pools are shut down after clearAllHandle() returns, so remaining handles still reach a running pool. Two open pull requests (#11394, #11421) already target this, so check them before starting.

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

描述

Before Creating the Bug Report
  • I found a bug, not just asking a question, which should be created in GitHub Discussions.
  • I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
  • I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment

OS: any (proxy module, receipt handle renewal)

RocketMQ version

branch: develop
Git commit id: a7edeecfb (2026-10-13; the file is unchanged by that commit)

JDK Version

Compiler: Temurin 1.8.0_504 (target 1.8, same as CI)

Describe the Bug

DefaultReceiptHandleManager never shuts down the two worker pools it creates.

The constructor creates both pools for itself:

this.renewalWorkerService = ThreadPoolMonitor.createAndMonitor(
    proxyConfig.getRenewThreadPoolNums(), proxyConfig.getRenewMaxThreadPoolNums(), 1, TimeUnit.MINUTES,
    "RenewalWorkerThread", proxyConfig.getRenewThreadPoolQueueCapacity());
this.returnHandleGroupWorkerService = ThreadPoolMonitor.createAndMonitor(
    proxyConfig.getReturnHandleGroupThreadPoolNums(), proxyConfig.getReturnHandleGroupThreadPoolNums() * 2,
    1, TimeUnit.MINUTES, "ReturnHandleGroupWorkerThread", proxyConfig.getRenewThreadPoolQueueCapacity());

but the shutdown registered with the manager's lifecycle only stops the scheduler and clears the handles:

public void shutdown() throws Exception {
    scheduledExecutorService.shutdown();
    clearAllHandle();
}

renewalWorkerService.shutdown() / returnHandleGroupWorkerService.shutdown() appear nowhere in the repository (only
creation and use), and the threads are not daemons (ThreadFactoryBuilder().setNameFormat(...), no setDaemon(true)), so
after the manager is shut down — e.g. an in-JVM proxy stop/restart (embedded use, integration tests, or a restart within one
process) — up to renewThreadPoolNums + returnHandleGroupThreadPoolNums (defaults 2 + 2, max doubled) threads plus their
queued renew/return tasks keep running against services that are being torn down.

Steps to Reproduce
  1. Run the proxy so at least one handle renewal is scheduled (enableProxyAutoRenew=true is the default).
  2. Stop the proxy in the same JVM (the manager's shutdown() runs through the proxy lifecycle).
  3. renewalWorkerService.isShutdown() and returnHandleGroupWorkerService.isShutdown() are both false; the
    RenewalWorkerThread-* / ReturnHandleGroupWorkerThread-* threads are still alive.
Expected behavior

shutdown() releases the pools it created, after the remaining handles have been handed back
(clearAllHandle() submits them to returnHandleGroupWorkerService).

Actual behavior

The two pools keep running past the shutdown.

Additional context

Fix: shut both pools down at the end of the manager's shutdown, after clearAllHandle() so the remaining handles are still
submitted to a running pool.

主要语言
Java
星标
22.7k
派生
12k
平均合并
3 天 18 小时
30 天内合并 PR
17

环境准备

从这里开始

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

apache/rocketmq 的其他 Issue

查看 apache/rocketmq 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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