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

KAFKA-18071: Avoid event to refresh regex if no pattern subscription #17917

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

lianetm
Copy link
Contributor

@lianetm lianetm commented Nov 22, 2024

Fix to check if the consumer has a pattern subscription before generating a background event to refresh the regex against metadata.

This happens as part of the poll loop, so avoiding the unnecessary event and block waiting for it (the check was performed in the background before this PR).

Checking hasSubscriptionPattern in the app thread should be safe because the subscription type only changes with api calls to subscribe/assign/unsubscribe, that all block until the subscription state is updated.

Copy link
Contributor

@dajac dajac left a comment

Choose a reason for hiding this comment

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

LGTM, assuming tests pass.

@@ -320,11 +320,12 @@ private void process(final TopicPatternSubscriptionChangeEvent event) {
* This will make the consumer send the updated subscription on the next poll.
*/
private void process(final UpdatePatternSubscriptionEvent event) {
if (!subscriptions.hasPatternSubscription()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this test really necessary? This event is only sent if the application thread knows there's a pattern subscription.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

truly it's not needed with the current usage of this event from the app thread. I just left it for extra protection in this thread really (ok to remove it if we prefer)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just checking my understanding. It looks like the remains of an earlier thought :)

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