You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "kuoche1712003 (via GitHub)" <gi...@apache.org> on 2026/05/13 15:46:18 UTC

[PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

kuoche1712003 opened a new pull request, #22279:
URL: https://github.com/apache/kafka/pull/22279

     Previously, `ConsumerNetworkThread.maybeFailOnMetadataError` would propagate a
     stored `metadataError` to the next incoming `MetadataErrorNotifiableEvent` without
     checking whether the error was still relevant to the current assignment. After
     `consumer.assign()` switched to a different topic, the new `AsyncPollEvent` could
     inherit a stale `TopicAuthorizationException` from the previous assignment and fail
     unexpectedly.
   
     Fix: before propagating the error, compare its topic set against the current
     assignment via `SubscriptionState.assignedPartitions()`. If the error topics are
     disjoint from the current assignment, the error is silently dropped. The underlying
     `Metadata.unauthorizedTopics` is already cleared by `maybeThrowAnyException`, so
     the next metadata refresh will re-surface the error if the topic is still relevant.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3389558840


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java:
##########
@@ -436,25 +437,24 @@ void cleanup() {
      * If there is a metadata error, complete all uncompleted events that require subscription metadata.
      */
     private boolean maybeFailOnMetadataError(List<?> events) {
-        List<MetadataErrorNotifiableEvent> filteredEvents = new ArrayList<>();
-
-        for (Object obj : events) {
-            if (obj instanceof MetadataErrorNotifiableEvent) {
-                filteredEvents.add((MetadataErrorNotifiableEvent) obj);
-            }
-        }
+        List<MetadataErrorNotifiableEvent> filteredEvents = events.stream()

Review Comment:
   Thanks for the heads up! I'll keep the for loop.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "muralibasani (via GitHub)" <gi...@apache.org>.
muralibasani commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3289834302


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:
##########
@@ -852,6 +853,13 @@ protected ApplicationEventProcessor create() {
         };
     }
 
+    public Set<String> currentlyRelevantTopics() {

Review Comment:
   ```suggestion
       public Set<String> subscribedAndAssignedTopics() {
   ```
   it was a bit vague imo



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-4671868870

   @lianetm Thanks for the thorough review! I've updated the logic to also propagate errors for transient topics.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3290418759


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used
+     * to drop exceptions captured before {@code assign()}/{@code subscribe()} from leaking
+     * to a new scope. Conservative on unknown types and empty {@code currentTopics}.
+     */
+    public static boolean isErrorProvablyUnrelated(Throwable t, Set<String> currentTopics) {
+        Throwable error = t;
+        if (error instanceof CompletionException) {

Review Comment:
   Good point — I looked into this. In this specific path the chain stays on plain CompletableFuture (never 
   crosses KafkaFutureImpl), and the JDK's CompletableFuture.encodeThrowable reuses an existing 
   CompletionException rather than re-wrapping, so nesting shouldn't occur here. ExecutionException only 
   surfaces via Future.get(), while we capture the error in a whenComplete callback.
   
   Existing single-layer unwraps in Errors.maybeUnwrapException:541 and ApplicationEventProcessor:815 follow the same reasoning, so I kept this consistent — but I'm happy to switch to a multi-layer loop if you'd prefer the extra safety margin. Let me know which you'd like.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "muralibasani (via GitHub)" <gi...@apache.org>.
muralibasani commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3289840742


##########
core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala:
##########
@@ -358,8 +358,10 @@ abstract class EndToEndAuthorizationTest extends IntegrationTestHarness with Sas
       topic2RecordConsumed = true
       false
     }
+    // pollTimeoutMs must outlast the metadata refresh: an empty poll result would fail
+    // verifyNoRecords {tp2} partition assertion before the auth exception is thrown.
     assertThrows(classOf[TopicAuthorizationException],
-      () => TestUtils.pollRecordsUntilTrue(consumer, verifyNoRecords, "Consumer didn't fail with authorization exception within timeout"))
+      () => TestUtils.pollRecordsUntilTrue(consumer, verifyNoRecords, "Consumer didn't fail with authorization exception within timeout", pollTimeoutMs = 200))

Review Comment:
   May be better to use a constant for `200`, instead of hardcoding.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "lianetm (via GitHub)" <gi...@apache.org>.
lianetm commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r4348831485


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerMetadata.java:
##########
@@ -107,6 +107,18 @@ synchronized void clearTransientTopics() {
         this.transientTopics.clear();
     }
 
+    /**
+     * Topics this consumer currently needs metadata for: subscribed topics, topics of assigned
+     * partitions, and transient topics registered temporarily by offset-related APIs. This is the
+     * same set of topics {@link #retainTopic(String, boolean, long)} keeps, so a metadata error
+     * about a topic outside this set cannot concern any of this consumer's pending operations.
+     */
+    public synchronized Set<String> subscribedAssignedAndTransientTopics() {

Review Comment:
   uhm this piece of logic seems to overlap with bits that already exist in metadata and subscription state, wonder if we should review them all to avoid ending up with different ways to identify the same (if a topic's metadata is relevant)
   
   E.g, `metadataTopics` (doesn't it already tell us the same as the new "subscribedOrAssignedTopics"?), also `retainTopic` (this is what we already use to know if the client keeps the metadata entry from response or drops it, also `needsMetadata`
   
   Ideally I would aim for a hook here on the metadata component, that just puts together all the hooks we already have to determine if a topic is still "relevant" (so we can be sure it's ok to throw the exception".  Maybe a combination of isTransient || needsMetadata || [regex, this seems a missing bit to consider in the PR?]...Still not 100% sure this is all but for sure it's part of it



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java:
##########
@@ -452,12 +454,18 @@ private boolean maybeFailOnMetadataError(List<?> events) {
             return false;
 
         Optional<Exception> metadataError = networkClientDelegate.getAndClearMetadataError();
+        if (metadataError.isEmpty())
+            return false;
 
-        if (metadataError.isPresent()) {
-            filteredEvents.forEach(e -> e.onMetadataError(metadataError.get()));
-            return true;
-        } else {
+        Set<String> relevantTopics = applicationEventProcessor.subscribedAssignedAndTransientTopics();
+        if (isErrorProvablyUnrelated(metadataError.get(), relevantTopics)) {
+            log.debug("Dropping metadata error deemed unrelated to currently relevant topics {}",
+                    relevantTopics, metadataError.get());

Review Comment:
   I'm still nervous about this :) 
   
   E.g., I don't see we consider regex. Client-side old regex, metadata for all topics is resolved on the client to compute it, would we drop auth errors here? Similar thought for the new R2j regex



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3290444872


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used

Review Comment:
   Done, thanks!



##########
core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala:
##########
@@ -358,8 +358,10 @@ abstract class EndToEndAuthorizationTest extends IntegrationTestHarness with Sas
       topic2RecordConsumed = true
       false
     }
+    // pollTimeoutMs must outlast the metadata refresh: an empty poll result would fail
+    // verifyNoRecords {tp2} partition assertion before the auth exception is thrown.
     assertThrows(classOf[TopicAuthorizationException],
-      () => TestUtils.pollRecordsUntilTrue(consumer, verifyNoRecords, "Consumer didn't fail with authorization exception within timeout"))
+      () => TestUtils.pollRecordsUntilTrue(consumer, verifyNoRecords, "Consumer didn't fail with authorization exception within timeout", pollTimeoutMs = 200))

Review Comment:
   Done, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-4643113349

   @kuoche1712003 would you mind creating a jira ticket? This PR seems to fix an existing issue where exceptions unrelated to the new subscription are thrown.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3369669745


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java:
##########
@@ -265,7 +267,11 @@ public CompletableFuture<Void> updateFetchPositions(long deadlineMs) {
 
     private boolean maybeCompleteWithPreviousException(CompletableFuture<Void> result) {
         Throwable cachedException = cachedUpdatePositionsException.getAndSet(null);
-        if (cachedException != null) {
+        Set<String> topics = Stream.concat(
+                subscriptionState.subscription().stream(),
+                subscriptionState.assignedPartitions().stream().map(TopicPartition::topic)
+        ).collect(Collectors.toUnmodifiableSet());
+        if (cachedException != null && !isErrorProvablyUnrelated(cachedException, topics)) {

Review Comment:
   Should we log it before those "unrelated" errors disappear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "lianetm (via GitHub)" <gi...@apache.org>.
lianetm commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-5284924792

   Sorry for the delay here, will take another look right after we get of of 4.4, thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r4366467103


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerMetadata.java:
##########
@@ -107,6 +107,18 @@ synchronized void clearTransientTopics() {
         this.transientTopics.clear();
     }
 
+    /**
+     * Topics this consumer currently needs metadata for: subscribed topics, topics of assigned
+     * partitions, and transient topics registered temporarily by offset-related APIs. This is the
+     * same set of topics {@link #retainTopic(String, boolean, long)} keeps, so a metadata error
+     * about a topic outside this set cannot concern any of this consumer's pending operations.
+     */
+    public synchronized Set<String> subscribedAssignedAndTransientTopics() {

Review Comment:
   Agree, makes sense to consolidate. Let me go through the existing checks and the regex case and I’ll follow up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "muralibasani (via GitHub)" <gi...@apache.org>.
muralibasani commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3289826377


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used
+     * to drop exceptions captured before {@code assign()}/{@code subscribe()} from leaking
+     * to a new scope. Conservative on unknown types and empty {@code currentTopics}.
+     */
+    public static boolean isErrorProvablyUnrelated(Throwable t, Set<String> currentTopics) {
+        Throwable error = t;
+        if (error instanceof CompletionException) {

Review Comment:
   It could be possible to have CompletionException has nested CompletionExceptions or an ExecutinException, and they are never reached. May be a multi-level unwrap is better?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "muralibasani (via GitHub)" <gi...@apache.org>.
muralibasani commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3290856958


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used
+     * to drop exceptions captured before {@code assign()}/{@code subscribe()} from leaking
+     * to a new scope. Conservative on unknown types and empty {@code currentTopics}.
+     */
+    public static boolean isErrorProvablyUnrelated(Throwable t, Set<String> currentTopics) {
+        Throwable error = t;
+        if (error instanceof CompletionException) {

Review Comment:
   I don't have a strong opinion about unwrapping, but will leave it to 2nd reviewer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3290418759


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used
+     * to drop exceptions captured before {@code assign()}/{@code subscribe()} from leaking
+     * to a new scope. Conservative on unknown types and empty {@code currentTopics}.
+     */
+    public static boolean isErrorProvablyUnrelated(Throwable t, Set<String> currentTopics) {
+        Throwable error = t;
+        if (error instanceof CompletionException) {

Review Comment:
   Good point — I looked into this. In this specific path the chain stays on plain CompletableFuture (never 
   crosses KafkaFutureImpl), and the JDK's CompletableFuture.encodeThrowable reuses an existing 
   CompletionException rather than re-wrapping, so nesting shouldn't occur here. ExecutionException only 
   surfaces via Future.get(), while we capture the error in a whenComplete callback.
   
   Existing single-layer unwraps in Errors.maybeUnwrapException:541 and ApplicationEventProcessor:815 follow the same reasoning, so I kept this consistent — but I'm happy to switch to a multi-layer loop if you'd prefer 
   the extra safety margin. Let me know which you'd like.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "muralibasani (via GitHub)" <gi...@apache.org>.
muralibasani commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3289828919


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used
+     * to drop exceptions captured before {@code assign()}/{@code subscribe()} from leaking
+     * to a new scope. Conservative on unknown types and empty {@code currentTopics}.
+     */
+    public static boolean isErrorProvablyUnrelated(Throwable t, Set<String> currentTopics) {
+        Throwable error = t;
+        if (error instanceof CompletionException) {
+            error = t.getCause();

Review Comment:
   should this be error.getCause() ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3290443434


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used
+     * to drop exceptions captured before {@code assign()}/{@code subscribe()} from leaking
+     * to a new scope. Conservative on unknown types and empty {@code currentTopics}.
+     */
+    public static boolean isErrorProvablyUnrelated(Throwable t, Set<String> currentTopics) {
+        Throwable error = t;
+        if (error instanceof CompletionException) {
+            error = t.getCause();

Review Comment:
   Done, thanks!



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:
##########
@@ -852,6 +853,13 @@ protected ApplicationEventProcessor create() {
         };
     }
 
+    public Set<String> currentlyRelevantTopics() {

Review Comment:
   Done, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-4661253445

   @chia7712 Thanks for the review! I've pushed the changes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "lianetm (via GitHub)" <gi...@apache.org>.
lianetm commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3382825162


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:
##########
@@ -852,6 +853,13 @@ protected ApplicationEventProcessor create() {
         };
     }
 
+    public Set<String> subscribedAndAssignedTopics() {
+        return Stream.concat(
+                subscriptions.subscription().stream(),
+                subscriptions.assignedPartitions().stream().map(TopicPartition::topic)
+        ).collect(Collectors.toUnmodifiableSet());

Review Comment:
   would this make more sense in the SubscriptionState class?
   
   Seems a kind of subscribedOrAssignedTopics() to me (exclusive, we can never have both at the same time) 



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java:
##########
@@ -436,25 +437,24 @@ void cleanup() {
      * If there is a metadata error, complete all uncompleted events that require subscription metadata.
      */
     private boolean maybeFailOnMetadataError(List<?> events) {
-        List<MetadataErrorNotifiableEvent> filteredEvents = new ArrayList<>();
-
-        for (Object obj : events) {
-            if (obj instanceof MetadataErrorNotifiableEvent) {
-                filteredEvents.add((MetadataErrorNotifiableEvent) obj);
-            }
-        }
+        List<MetadataErrorNotifiableEvent> filteredEvents = events.stream()

Review Comment:
   I wonder if we were intentionally using the for loop and avoiding the streams api because we're in the hot path here? (this is called on each iteration of the background thread loop)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-4504848126

   A label of 'needs-attention' was automatically added to this PR in order to raise the
   attention of the committers. Once this issue has been triaged, the `triage` label
   should be removed to prevent this automation from happening again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-4521557576

   @muralibasani Thanks for the review! I've pushed the changes and left some comments


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Enable testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl f… [kafka]

Posted by "muralibasani (via GitHub)" <gi...@apache.org>.
muralibasani commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3289835687


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerUtils.java:
##########
@@ -260,4 +263,22 @@ public static KafkaException maybeWrapAsKafkaException(Throwable t, String messa
         else
             return new KafkaException(message, t);
     }
+
+    /**
+     * {@code true} iff the error names topics disjoint from {@code currentTopics} — used

Review Comment:
   ```suggestion
        * {@code true} if the error names topics disjoint from {@code currentTopics} — used
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3389557651


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:
##########
@@ -852,6 +853,13 @@ protected ApplicationEventProcessor create() {
         };
     }
 
+    public Set<String> subscribedAndAssignedTopics() {
+        return Stream.concat(
+                subscriptions.subscription().stream(),
+                subscriptions.assignedPartitions().stream().map(TopicPartition::topic)
+        ).collect(Collectors.toUnmodifiableSet());

Review Comment:
   Good point, I'll move it to SubscriptionState.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "kuoche1712003 (via GitHub)" <gi...@apache.org>.
kuoche1712003 commented on code in PR #22279:
URL: https://github.com/apache/kafka/pull/22279#discussion_r3374720733


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java:
##########
@@ -265,7 +267,11 @@ public CompletableFuture<Void> updateFetchPositions(long deadlineMs) {
 
     private boolean maybeCompleteWithPreviousException(CompletableFuture<Void> result) {
         Throwable cachedException = cachedUpdatePositionsException.getAndSet(null);
-        if (cachedException != null) {
+        Set<String> topics = Stream.concat(
+                subscriptionState.subscription().stream(),
+                subscriptionState.assignedPartitions().stream().map(TopicPartition::topic)
+        ).collect(Collectors.toUnmodifiableSet());
+        if (cachedException != null && !isErrorProvablyUnrelated(cachedException, topics)) {

Review Comment:
   Done, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20669: Fix Consumer propagates stale TopicAuthorizationException/InvalidTopicException after subscription change [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #22279:
URL: https://github.com/apache/kafka/pull/22279#issuecomment-6333387052

   @kuoche1712003 please fix the conflicts :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org