jolshan commented on code in PR #16344:
URL: https://github.com/apache/kafka/pull/16344#discussion_r2518990262
##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -1176,18 +1177,25 @@ private ClusterAndWaitTime waitOnMetadata(String topic,
Integer partition, long
metadata.awaitUpdate(version, remainingWaitMs);
} catch (TimeoutException ex) {
// Rethrow with original maxWaitMs to prevent logging
exception with remainingWaitMs
- throw new TimeoutException(
- String.format("Topic %s not present in metadata after
%d ms.",
- topic, maxWaitMs));
+ final String errorMessage = String.format("Topic %s not
present in metadata after %d ms.",
+ topic, maxWaitMs);
+ if (metadata.getError(topic) != null) {
+ throw new TimeoutException(errorMessage,
metadata.getError(topic).exception());
+ }
+ throw new TimeoutException(errorMessage);
}
cluster = metadata.fetch();
elapsed = time.milliseconds() - nowMs;
if (elapsed >= maxWaitMs) {
- throw new TimeoutException(partitionsCount == null ?
+ final String errorMessage = partitionsCount == null ?
String.format("Topic %s not present in metadata after
%d ms.",
topic, maxWaitMs) :
String.format("Partition %d of topic %s with partition
count %d is not present in metadata after %d ms.",
- partition, topic, partitionsCount, maxWaitMs));
+ partition, topic, partitionsCount, maxWaitMs);
+ if (metadata.getError(topic) != null &&
metadata.getError(topic).exception() instanceof RetriableException) {
Review Comment:
Just to make sure I understand correctly--you are asking why we aren't
including the throwable for non-retriable exceptions?
My understanding -- and from the discussion above is that we want clearer
errors when we keep retrying over and over until we timeout. I'm not sure if
there is a case where we hit this and the error is not retriable?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]