-
Notifications
You must be signed in to change notification settings - Fork 914
Unprocessed records due to wrong offset in on_assign callback in consumer.subscribe() #1329
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
Comments
-1001 is the unset offset, e.g., no value. If you have auto-commit disabled, and fail to commit on rebalance (because the partition is no longer owned), then there will be no committed offset to resume from, so it will employ auto.offset.reset which you've set to latest, thus skipping messages. Do note though that you are setting A recommended approach to control what is being committed is to set |
Even if one commit fail, there might be earlier successful commits by other consumers, shouldn't it use that? Or there might no earlier committed offset in this case (which is highly unlikely though)? Also we don't want to set the offset to -2 in assign() (as mentioned here) as it will lead to re-processing of all the messages.
my bad, we are actually setting both.
What's the added benefit here? |
@edenhill ping.. |
It will use a previously committed offset first, if available.
At least once delivery. Fine-grained offset commit control. |
Thanks @edenhill for answering the questions. |
I have noticed that all of TopicPartition list we are receiving as part of consumer reassignment in It is happening regardless of whether there is a previously committed offset present or not. I tried to look in
We are also seeing continuous rebalancing (assignments and revokes) |
Oh this explains |
Description
TopicPartitions list I am receiving after consumer rebalancing (in
on_assign
callback) has offset set to -1001 for each partition.Timeline:
10:22:05 partition x got revoked
10:22:15 some messages were produced at partition x
10:22:17 previous on-going commit failed due to rebalancing (
KafkaError.REBALANCE_IN_PROGRESS
)10:22:17 partition x got re-assigned to a consumer
That's it. The new consumer never read the messages produced during re-balancing.
Notable config:
'auto.offset.reset': 'latest'
'auto.commit.enable': False
'confluent_kafka.version()': cp-kafka:5.0.0-1
OS: linux
I checked the logs and saw that
on_assign
callback contains list of topic partitions with offset set to -1001 and since this is out of bound offset, my guess is offset is falling back to 'latest', hence missing some of the messages.How to reproduce
Checklist
Please provide the following information:
confluent_kafka.version()
andconfluent_kafka.libversion()
):{...}
'debug': '..'
as necessary)The text was updated successfully, but these errors were encountered: