zjncs opened a new pull request, #11095:
URL: https://github.com/apache/rocketmq/pull/11095
### Motivation
When a broker has `coldDataFlowControlEnable=true` and a consumer group is
flagged for cold-data flow control (`ColdDataCgCtrService`), the cold branch of
`PullMessageProcessor` does:
```java
ConsumeType consumeType = this.brokerController.getConsumerManager()
.getConsumerGroupInfo(requestHeader.getConsumerGroup()).getConsumeType();
```
`getConsumerGroupInfo(group)` only consults the **live** consumer table. But
pull requests that carry their subscription in the request (proxy / lite-pull
traffic, i.e. `hasSubscriptionFlag=true\)) never registered the group there —
the broker instead compensates the group's basic info into
`consumerCompensationTable` a few lines earlier (`compensateBasicConsumerInfo`,
`PullMessageProcessor` L381-392). For those requests the lookup returns null
and the pull thread dies with:
```
java.lang.NullPointerException: Cannot invoke
"ConsumerGroupInfo.getConsumeType()"
because the return value of "ConsumerManager.getConsumerGroupInfo(String)"
is null
```
So a flow-controlled group reading cold data via the proxy gets NPE
responses instead of the intended flow control.
### Changes
- Look the group up with `getConsumerGroupInfo(group, true)` so the
compensation table filled a few lines above is also consulted (same pattern as
`ConsumerLagCalculator`).
- If even the compensation table has no record, fall back to
`CONSUME_PASSIVELY` — the conservative flow-control response — instead of
dereferencing null.
### Verification
New test
`PullMessageProcessorTest#testColdDataFlowCtrWhenGroupIsOnlyInCompensationTable`:
enables cold-data flow control, flags the group via `coldAcc`, unregisters the
live consumer, mocks a `DefaultMessageStore` whose commit log reports the
offset as cold, and sends a subscription-carrying pull request.
```
$ mvn -pl broker test -Dtest='PullMessageProcessorTest'
(before) java.lang.NullPointerException: Cannot invoke ... getConsumeType()
... is null
(after) Tests run: 11, Failures: 0, Errors: 0 (new test asserts
SYSTEM_BUSY + cold-data remark)
```
--
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]