unbridled-41 opened a new pull request, #11040:
URL: https://github.com/apache/rocketmq/pull/11040
### Problem / Evidence
With `enableFastChannelEventProcess=true`, the fast channel-close path in
`ConsumerManager#doChannelCloseEvent` cleans up a consumer channel by iterating
`ClientChannelAttributeHelper.getConsumerGroups(channel)`. That attribute is
only written in the full `registerConsumer` (`r1` branch).
`registerConsumerWithoutSub` — the path taken by heartbeat-v2 whenever the
client's subscription fingerprint is unchanged (`withoutSub=true`, the normal
reconnect case after broker restart / idle connection drop) — registers the
channel in `consumerTable` but never writes the attribute.
Consequences (verified in code):
- A consumer registered on a channel **only** via withoutSub heartbeats is
never removed by the fast close path: `getConsumerGroups` returns empty, the
cleanup loop is skipped, `doChannelCloseEvent` returns false.
- A later full heartbeat on the same channel cannot repair it, because
`updateChannel` returns false for an already-registered channel, so
`registerConsumer`'s `r1`-guarded `addConsumerGroup` is not reached.
The dead entry lingers in `consumerTable` until `scanNotActiveChannel`
expires it (`channelExpiredTimeout`, default 120s), delaying `UNREGISTER`
(ConsumerFilterManager cleanup) and leaving stale entries in consumer
connection queries.
Regression test
`ConsumerManagerTest#testWithoutSubRegistrationRemovedOnFastChannelClose` fails
before the fix (`removed == false`, group still in `consumerTable`) and passes
after.
### Root cause / Fix
Mirror the `registerConsumer` attribute bookkeeping in
`registerConsumerWithoutSub`: call
`ClientChannelAttributeHelper.addConsumerGroup(channel, group)` when the
channel was added/updated and fast channel event processing is enabled.
### Priority
PRIORITY = 72:影响 26(broker 重启/连接重建场景下失效消费者在 consumerTable 残留至 120s,延迟
UNREGISTER 通知与过滤器清理,污染连接列表——心跳 v2 常规路径)+ 波及范围 12(ConsumerManager fast 路径,单方法)+
可复现性 20(确定性单元测试,EmbeddedChannel)+ 维护价值 14(与 registerConsumer
既有模式对齐,修复极小)。FIX_CONFIDENCE = 85。
### Tests
- `mvn -pl broker test
-Dtest=ConsumerManagerTest#testWithoutSubRegistrationRemovedOnFastChannelClose`
- before fix (ff8f6f74c + test only): `Tests run: 1, Failures: 1`
- after fix: `Tests run: 1, Failures: 0`
- `mvn -pl broker test -Dtest=ConsumerManagerTest`: 14/14
- `mvn -pl broker test
-Dtest=ConsumerManagerScannerTest,ClientManageProcessorTest`: 9/9
### Risk
Low. The added attribute write only occurs on the `updateChannel == true`
branch (new channel), same condition as the existing `registerConsumer`
bookkeeping; `ClientChannelAttributeHelper.addConsumerGroup` is a no-op for
inactive channels. The attribute is consumed only by the fast close path, so
behavior without `enableFastChannelEventProcess` is unchanged.
--
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]