-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-7941: Catch TimeoutException in KafkaBasedLog worker thread #6283
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
Changes from all commits
eb85986
43c4fd9
1c8285a
818923c
0451311
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |||||||
| import org.apache.kafka.common.KafkaException; | ||||||||
| import org.apache.kafka.common.PartitionInfo; | ||||||||
| import org.apache.kafka.common.TopicPartition; | ||||||||
| import org.apache.kafka.common.errors.TimeoutException; | ||||||||
| import org.apache.kafka.common.errors.WakeupException; | ||||||||
| import org.apache.kafka.common.utils.Time; | ||||||||
| import org.apache.kafka.common.utils.Utils; | ||||||||
|
|
@@ -312,6 +313,10 @@ public void run() { | |||||||
| try { | ||||||||
| readToLogEnd(); | ||||||||
| log.trace("Finished read to end log for topic {}", topic); | ||||||||
| } catch (TimeoutException e) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are a couple of other places where we call kafka/connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Line 332 in 176ea0d
kafka/connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Line 153 in 176ea0d
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the additional eyes @wicknicks ! The The kafka/connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Line 267 in 176ea0d
|
||||||||
| log.warn("Timeout while reading log to end for topic '{}'. Retrying automatically. " + | ||||||||
| "This may occur when brokers are unavailable or unreachable. Reason: {}", topic, e.getMessage()); | ||||||||
| continue; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to backoff the retry, as the timeout probably means the unavailability of the resource (it might be the kafka broker itself, or the network, or something else), an immediate retry likely will not be success.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In practice, actual retries to the network will still be beholden to the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true, thanks for refreshing my mind. Then no need to backoff here. |
||||||||
| } catch (WakeupException e) { | ||||||||
| // Either received another get() call and need to retry reading to end of log or stop() was | ||||||||
| // called. Both are handled by restarting this loop. | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgwhalen, after thinking about this some more, I think we should keep this older signature, deprecate it, and have it call
setPollException(exception). AlthoughMockConsumeris strictly speaking a non-public API, doing this will help avoid problems should people use theMockConsumerclass in their tests. And it'd probably help to add JavaDoc that says to usesetPollException(...)instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I forgot it was a mildly public API. I added it back, should be good to merge now unless anything else stands out.