iloveeyjafjalla opened a new issue, #11393:
URL: https://github.com/apache/rocketmq/issues/11393

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] 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:
   
   ```java
   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:
   
   ```java
   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to