Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] The consumeFromWhere configuration didn't work in some cases. #9083

Open
3 tasks done
humkum opened this issue Dec 26, 2024 · 2 comments
Open
3 tasks done

[Bug] The consumeFromWhere configuration didn't work in some cases. #9083

humkum opened this issue Dec 26, 2024 · 2 comments

Comments

@humkum
Copy link
Contributor

humkum commented Dec 26, 2024

Before Creating the Bug Report

  • I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.

Runtime platform environment

Ubuntu 18.04

RocketMQ version

5.3

JDK Version

Open_JDK 1.8.0_202

Describe the Bug

PushConsumer and LitePullConsumer's consumeFromWhere configuration didn't work in follow situation:

  1. New created topic
  2. New created consumerGroup
  3. There are some messages in topic's queue, which are not expired
  4. The value of (maxOffset - 0) not over the size the broker thought is in memory.
    image

Steps to Reproduce

  1. Create a new Topic
  2. Send some messages to the topic
  3. Create a new Push/LitePull Consumer, and start to consume message from the topic created, with the consumeFromWhere default configured as ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET
  4. We would find that the consumer didn't consume from the last offset, it would consume from the earliest offset 0.

What Did You Expect to See?

The consumer consume from the last offset or consume from the timestamp user configured.

What Did You See Instead?

The consumer consume from the earliest offset 0.

Additional Context

Root cause as follows:
When new created consumer first consume from a topic, it would compute the offset from where to pull message. Because the brokers don't have it's consume offset, so the normal offset result should be computed as the consumeFromWhere's value, ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET, ConsumeFromWhere.CONSUME_FROM_EARLIEST_OFFSET,ConsumeFromWhere.CONSUME_FROM_TIMSTAMP, etc.
In computePullFromWhereWithException function: the consumer would query offset from the brokers to check if the brokers had the consumer offset. If not, it would set the pull offset to min/max offset or the offset corresponding to the timestamp configured, as follows:
image

But in broker side, it the consumer start pull message for the first time, that there's no consume offset for it. If the min offset equals to 0, and the value of (max offset - min offset) is considered as in memory, the read offset would returned as 0. So the consumer would consume from 0, even it set consumeFromWhere as from last offset or from timestamp. As follows:
image

@qianye1001
Copy link
Contributor

This is a protection measure. When a broker scales out, the registered topic route might become visible to Producers first, causing some messages to be sent. If the Consumer starts consuming from the latest offset at this time, these messages would be skipped.

@humkum
Copy link
Contributor Author

humkum commented Dec 27, 2024

This is a protection measure. When a broker scales out, the registered topic route might become visible to Producers first, causing some messages to be sent. If the Consumer starts consuming from the latest offset at this time, these messages would be skipped.

I get it, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants