kafka_consumer: prefilter consumer groups before fetching offsets - #25232
namtran1812 wants to merge 1 commit into
Conversation
✅ Dispatcher tests · passed
Batches
18e7520 — GitHub Run.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59ac06f530
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return [ | ||
| grp | ||
| for grp in self.client.list_consumer_groups() | ||
| if grp and self.config._consumer_groups_compiled_group_regex.match(grp) |
There was a problem hiding this comment.
Require the prefilter to match the complete group ID
re.Pattern.match() accepts prefix matches, while the existing combined expression requires the group pattern to reach the comma separating the group from its topic. For example, consumer_groups_regex: {'orders': {}} should select only orders, but this prefilter also fetches offsets for orders-v2, orders-archive, and every other prefixed group before the later tuple-level filter discards them. On clusters with many similarly named groups—especially when a literal group is paired with a topic regex—this can preserve the large offset-fetch fan-out that the change is intended to eliminate; use a whole-ID or delimiter-aware match.
Useful? React with 👍 / 👎.
|
🎯 Code Coverage (details) 🔗 Commit SHA: 59ac06f | Docs | View more details | Give us feedback! |
What does this PR do?
Filters discovered Kafka consumer groups against
consumer_groups_regexbefore fetching their offsets.Previously, when
consumer_groups_regexwas configured, the check discovered all consumer groups and passed all of them tolist_consumer_group_offsets. Regex filtering happened only afterward at the consumer group/topic/partition level.This keeps the existing topic/partition filtering behavior while adding a group-level prefilter before offset retrieval.
Motivation
On clusters with many consumer groups, a narrow
consumer_groups_regexcould still result in offset requests for every discovered group.For example, a regression test with 1,000 discovered groups and 10 matching groups verifies that only the 10 matching groups are submitted for offset retrieval, reducing the offset-fetch fan-out by 99% in that scenario.
monitor_unlisted_consumer_groupscontinues to bypass the prefilter and monitor all discovered groups.Fixes #24911
Testing
consumer_groupsandconsumer_groups_regex.monitor_unlisted_consumer_groupscontinues to fetch all groups.git diff --checkpasses.