Drifter-yh opened a new pull request, #11593:
URL: https://github.com/apache/rocketmq/pull/11593

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11039
   
   ### Brief Description
   
   With `enableFastChannelEventProcess=true`, 
`ConsumerManager#doChannelCloseEvent` cleans up a closed channel by iterating 
`ClientChannelAttributeHelper.getConsumerGroups(channel)`. That 
`CHANNEL_CONSUMER_GROUP` attribute is written only by 
`ConsumerManager#registerConsumer`, and only on the `updateChannel()` result 
being `true`.
   
   `registerConsumerWithoutSub` — the path heartbeat-v2 takes when the client's 
subscription fingerprint is unchanged (`withoutSub=true`, the normal case for a 
reconnecting client after a broker restart or an idle connection drop) — 
registers the channel in `consumerTable` via `updateChannel`, but never writes 
the attribute. As a result:
   
   - a consumer registered on a channel only through withoutSub heartbeats is 
never removed by the fast close path: `getConsumerGroups(channel)` is empty, 
the cleanup loop is skipped and `doChannelCloseEvent` returns `false`;
   - a later full heartbeat cannot repair it either, because 
`ConsumerGroupInfo#updateChannel` returns `false` for an already-registered 
channel, so the `r1`-guarded `addConsumerGroup` call in `registerConsumer` is 
never reached.
   
   The stale entry then stays in `consumerTable` until `scanNotActiveChannel` 
expires it after `channelExpiredTimeout` (120s by default), delaying the 
`UNREGISTER` event / `ConsumerFilterManager` cleanup and leaving stale entries 
in consumer connection queries.
   
   This PR mirrors the `registerConsumer` attribute bookkeeping in 
`registerConsumerWithoutSub`: when fast channel event processing is enabled and 
the channel was newly registered, call 
`ClientChannelAttributeHelper.addConsumerGroup(channel, group)`.
   
   ### How Did You Test This Change?
   
   New regression test 
`ConsumerManagerTest#testWithoutSubRegistrationRemovedOnFastChannelClose`:
   
   - puts a `ConsumerGroupInfo` with a subscription into `consumerTable` (state 
left by the previous full heartbeat),
   - calls `registerConsumerWithoutSub` with a fresh `EmbeddedChannel` (the 
heartbeat-v2 `withoutSub` reconnect),
   - asserts the channel carries the consumer group attribute,
   - fires `doChannelCloseEvent` and asserts it returns `true` and the group is 
removed from `consumerTable`.
   
   Evidence (`mvn -pl broker -am -Dtest=ConsumerManagerTest test`, JDK 17):
   
   - without the production change (test only): `Tests run: 13, Failures: 1` — 
the attribute assertion fails with `Expecting EmptyList: [] to contain: 
["DEFAULT_GROUP"]`
   - with the fix: `Tests run: 14, Failures: 0, Errors: 0, Skipped: 0`
   
   Additional checks:
   
   - `mvn -pl broker -am 
-Dtest=ConsumerManagerScannerTest,ClientManageProcessorTest test` → 3/3 and 6/6 
pass
   - `mvn -pl broker -am -DskipTests install` with checkstyle enabled → `0 
Checkstyle violations` for `rocketmq-broker`
   
   Closes #11039
   
   <!-- Note: this is the same minimal fix as the earlier closed PR #11040, 
re-submitted with the regression test. -->
   


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

  • [PR] [ISSUE #11039] Track consu... Drifter-yh (via GitHub) via commits

Reply via email to