qianye1001 opened a new issue, #11072: URL: https://github.com/apache/rocketmq/issues/11072
### Runtime platform environment Source-level shutdown race; the proposed regression tests were run locally on macOS. ### RocketMQ version Apache RocketMQ `develop`, base commit `66362b9c9f` (5.5.1 development version). ### JDK Version Tests: Amazon Corretto 21.0.5, compiling the project's Java 8 source/target. ### Describe the Bug NameServer route queries do not check whether NameServer shutdown has begun. `NamesrvController.shutdown()` starts closing resources, while `ClientRequestProcessor` only checks startup readiness. A queued or running `GET_ROUTEINFO_BY_TOPIC` request can therefore still return a route result while the NameServer is shutting down. Broker connection cleanup can remove route entries during this interval. A successful response containing a reduced route can replace a client's previously cached route. A query may also return `TOPIC_NOT_EXIST` when the intended condition is that the NameServer is no longer ready to serve route queries. ### Steps to Reproduce The relevant interleaving is: 1. Admit or queue a topic route query on a running NameServer. 2. Begin `NamesrvController.shutdown()` through `mqshutdown namesrv` or SIGTERM. 3. Allow the query to execute or finish while shutdown and Broker connection cleanup proceed. 4. Observe that the route processor has no shutdown readiness check before returning its result. This report is based on the code path and deterministic regression tests for the proposed fix, rather than a production reproduction. The tests cover shutdown before request processing and shutdown during route lookup, with both a route result and a missing route. ### What Did You Expect to See? Once shutdown starts, route queries that are still being processed should return `SYSTEM_ERROR` with `name server not ready` and no route body. This should apply independently of client version and the startup readiness configuration. A response fully constructed before shutdown starts may still be returned. If the connection has already closed, a connection failure is also expected. ### What Did You See Instead? The processor continues its normal route lookup and can return `SUCCESS` or `TOPIC_NOT_EXIST` during shutdown. Startup readiness alone does not cover this interval. ### Additional Context A small fix is sufficient: mark the controller as shutting down before resource cleanup, and check that state before route lookup and again before returning the response. Checking twice covers queries already executing when shutdown starts. -- 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]
