Skip to content

KafkaConsumer does not revoke deleted partitions when using a ConsumerRebalanceListener #1527

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

Closed
seifertm opened this issue Jun 22, 2018 · 2 comments
Labels

Comments

@seifertm
Copy link

In my system, a KafkaConsumer uses a regex subscription to subscribe to topics in the form of <user_id>.<topic>. A ConsumberRebalanceListener is used to write topic offsets and the aggregated topic states into a local cache. Automated tests create and delete users (i.e. topics).

When new topics are created, everything works fine. The logs show that the subscription changed, currently subscribed partitions are revoked and the partitions of the created topics are added to the set of previously assigned TopicsPartitions.

When a topic is deleted (via a DeleteTopicsRequest), the log shows that the subscription changes ("Updatding subscribed topics to: …"). The subscription no longer contains the deleted topics, which is correct. Afterwards the currently assigned partitions are revoked in ConsumerCoordinator._on_join_prepare ("Revoking previously assigned partitions …"). However, the set of revoked partitions no longer contains the partitions of the deleted topic, because the subscription was already updated.

I would expect that deleted TopicPartitions are also passed to ConsumerRebalanceListener.on_partitions_revoked. Is my expectation wrong or is this a bug?

@tvoinarovskyi
Copy link
Collaborator

Hmm, It would be interesting to see what Java does in this case. While it seems logical to get those partitions, you can't do anything with them in contrast to the rest of partitions. Both solutions have downsides...

@dpkp dpkp added the consumer label Mar 18, 2025
@dpkp
Copy link
Owner

dpkp commented Mar 27, 2025

I believe this is KIP-70 / #1242 and has now been fixed.

@dpkp dpkp closed this as completed Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants