Skip to content

Conversation

@AntonVasant
Copy link
Contributor

This PR fixes an issue in GroupMetadataManager#maybeUpdateRegularExpressions where a member’s regex subscription transition from non-empty → empty did not trigger a group epoch bump.
The method previously returned REGEX_UPDATED, which does not cause consumerGroupHeartbeat to increment the group epoch.

Fix
The patch updates the logic to return:
REGEX_UPDATED_AND_RESOLVED

when:

the updated regex subscription text is empty, and
the previous subscription was non-empty.
This ensures that consumerGroupHeartbeat correctly bumps the group epoch, keeping the group metadata consistent.

Tests

Several tests were updated to align with the corrected behavior.
Tests that previously expected no epoch bump were failing, and have now been adjusted to expect the new, correct logic.

JIRA
https://issues.apache.org/jira/browse/KAFKA-19891

Impact

Fixes coordinator state correctness for regex-subscribing consumer groups
Ensures group epoch bumps happen for all relevant subscription transitions
Backward compatible
No public API changes

…ons from non-empty to empty

This patch fixes an issue in
where  was incorrectly set to
when a member’s regex subscription transitions from non-empty to empty.

Because  does not trigger a group epoch bump in
, the group metadata could remain stale. The fix
updates the method to return  in this case,
ensuring the group epoch is correctly incremented.

The patch also updates tests that relied on the previous behavior and were
failing due to the corrected epoch bump logic.
@github-actions github-actions bot added triage PRs from the community group-coordinator labels Nov 28, 2025
Copy link
Contributor

@squah-confluent squah-confluent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! I don't think the fix is in the correct place.

Comment on lines 3310 to 3313

if (isNotEmpty(oldSubscribedTopicRegex) && group.numSubscribedMembers(oldSubscribedTopicRegex) != 0) {
updateRegularExpressionsResult = UpdateRegularExpressionsResult.REGEX_UPDATED_AND_RESOLVED;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're changing the return value in the wrong branch of the code. We want the branch where newSubscribedTopicRegex is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean the regex itself is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and not the subscribers counts is empty for the new regex?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. When we trigger a refresh we do not want to bump the group epoch until the refresh is complete. The refresh will bump the group epoch for us once it has mapped the regex to a list of topics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, will make the changes accordingly

Comment on lines 1467 to 1468
mkTopicAssignment(fooTopicId, 3, 4, 5),
mkTopicAssignment(barTopicId, 2)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid changing the formatting of unrelated tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, correcting this

@dajac dajac removed the triage PRs from the community label Nov 28, 2025
@dajac dajac self-requested a review November 28, 2025 13:08
…cRegex is empty

This patch corrects the return value in
for the case where a member's  becomes empty.

Previously, the branch handling this condition returned , which does not
trigger a group epoch bump during . As a result, the coordinator
could retain stale group metadata when a member unsubscribed from all regex-based topics.

The fix updates the method to return  specifically when the
new subscribed regex string is empty, ensuring that the coordinator clears the member's
assignment and correctly bumps the group epoch.
…ting regex empty-branch logic

This commit reverts test modifications that were made under the earlier,
incorrect assumption about the behavior when  becomes empty.
Now that the fix applies to the correct branch, the tests no longer need
their previous adjustments, and their original expectations are valid again.
@github-actions github-actions bot added the small Small PRs label Nov 28, 2025
…cRegex is empty

This patch corrects the return value in
for the case where a member's  becomes empty.
Previously, the branch handling this condition returned , which does not
trigger a group epoch bump during . As a result, the coordinator
could retain stale group metadata when a member unsubscribed from all regex-based topics.
The fix updates the method to return REGEX_UPDATED_AND_RESOLVED.
@dajac
Copy link
Member

dajac commented Nov 29, 2025

@AntonVasant Could you please add a unit test to cover the change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants