RockteMQ-AI commented on issue #10955: URL: https://github.com/apache/rocketmq/issues/10955#issuecomment-5370178943
Hi @DeerplayHub, thanks for reporting this! I've analyzed this issue against the codebase and can confirm this appears to be a **real bug**. **Root Cause:** In `DefaultMQPushConsumerImpl.pullMessage()` (line 308), for an orderly consumer's first pull, `computePullFromWhereWithException` is called a second time to "fix" the offset. When the consumer has no committed offset (first start, `CONSUME_FROM_LAST_OFFSET`), this re-queries `maxOffset` from the broker. If any new message arrived between the rebalance call and this second call (~1 second later), `maxOffset` has advanced, and `pullRequest.setNextOffset(offset)` overwrites the originally-computed offset with the new higher value, silently skipping the messages that arrived in between. **Affected Files:** client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java, client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java, client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java **Analysis:** The double-call to `computePullFromWhere` — once at rebalance (RebalanceImpl.java:477) and again at first pull time (DefaultMQPushConsumerImpl.java:308) — is intentional for correcting stale offsets, but it creates a race window: for a fresh consumer with no committed offset, both calls invoke `maxOffset()`, and if the queue advances between them, the initial offset is discarded. The messages produced in that gap are lost. I'll prepare a fix spec and work on a PR. The community is welcome to provide feedback on the approach before implementation. --- 🤖 *Automated issue analysis by github-manager* -- 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]
