gogodjzhu opened a new pull request, #11310:
URL: https://github.com/apache/rocketmq/pull/11310

   ### Which Issue(s) This PR Fixes
   
   Fixes #11309
   
   ### Brief Description
   
   PushConsumer shutdown can race with asynchronous rebalance from the shared
   `RebalanceService`.
   
   The asynchronous rebalance path calls
   `DefaultMQPushConsumerImpl.tryRebalance()`, while the existing lifecycle
   protection only covered `shutdown()` and `doRebalance()`. Therefore,
   `tryRebalance()` could continue creating `ProcessQueue` instances and
   dispatching `PullRequest`s after `shutdown()` destroyed `RebalanceImpl`.
   
   This could leave an orphan `ProcessQueue` that is still referenced by a 
queued
   pull request but is no longer managed by the consumer's
   `processQueueTable`. Such queues may continue to trigger unnecessary pull
   work, miss normal lifecycle cleanup, and leave message-processing state
   detached from the stopped consumer.
   
   This PR:
   
   - synchronizes `tryRebalance()` with the Consumer lifecycle lock;
   - skips `tryRebalance()` when the Consumer is not in `RUNNING` state;
   - updates the regression test to invoke `MQClientInstance.doRebalance()`, 
which
     covers the same asynchronous `tryRebalance()` path used by
     `RebalanceService`;
   - verifies that shutdown waits for an in-flight asynchronous rebalance and 
that
     rebalance after shutdown does not access `RebalanceImpl`.
   
   ### How Did You Test This Change?
   
   ```bash
   mvn -pl client 
-Dtest=DefaultMQPushConsumerTest#testShutdownWaitsForInFlightAsyncRebalance test
   mvn -pl client -Dtest=DefaultMQPushConsumerTest#testGracefulShutdown test
   ```
   
   Both commands passed.
   
   Also ran:
   
   ```bash
   mvn -pl client test
   ```
   
   The full Client test run executed 450 tests. One existing
   `DefaultMQPushConsumerTest.testGracefulShutdown` invocation timed out because
   background client threads attempted to connect without a NameServer during 
the
   combined run. The same test passes when run independently, and the new
   regression test passes deterministically.
   


-- 
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