#11151·rocketmq

[Bug] Remoting sub-servers do not honor graceful shutdown

Author: qianye1001Created Sep 11, 2026Updated Sep 17, 2026

Runtime platform environment

macOS aarch64, JDK 11.

RocketMQ version

develop, commit d38f81e787.

Describe the Bug

Sub-servers created by NettyRemotingServer.newRemotingServer(port) do not honor the parent's graceful-shutdown configuration. SubRemotingServer.shutdown() sets its shutdown flag and immediately closes its listening channel. During the configured grace period, new connections therefore fail instead of receiving GO_AWAY responses for supported client versions.

Calling only the parent's shutdown() has another gap: it marks only the parent as shutting down, so sub-servers can continue processing requests until the shared event loops shut down. Concurrent shutdown calls also need coordination: a repeated call must not bypass the first call's grace period and close the listener or shared resources early.

Steps to Reproduce

  1. Start a NettyRemotingServer with enableShutdownGracefully=true and shutdownWaitTimeSeconds=5.
  2. Create and start sub-servers on other ports, and register a request processor on each server.
  3. Establish a connection and send a request using a protocol version newer than V5_3_1.
  4. Call a sub-server's shutdown() on another thread. During the grace period, send another request over the existing connection and try a fresh connection to that port.
  5. Separately, call only the parent server's shutdown() and send requests to the sub-server ports during the grace period.

What Did You Expect to See?

A standalone sub-server shutdown keeps its listener available during the configured grace period and uses the existing GO_AWAY handling, without shutting down other ports or shared resources.

Each sub-server measures its own grace period from when it first enters the draining state. Repeated shutdown calls must not reset that deadline. A parent shutdown marks all its sub-servers as draining and waits until its own and all child grace periods have elapsed before releasing shared resources. Main/sub shutdowns and repeated calls may run concurrently; the independent grace periods must overlap rather than being waited one after another.

What Did You See Instead?

The standalone sub-server closes its listener immediately. Parent-only shutdown leaves sub-servers outside the draining state. A regression test on the unmodified commit times out waiting for a child to enter that state after parent shutdown starts.