Skip to content

KAFKA-12879: Revert changes from KAFKA-12339 and instead add retry capability to KafkaBasedLog#11797

Merged
rhauch merged 29 commits into
apache:trunkfrom
philipnee:kafka-12879-connect
Mar 9, 2022
Merged

KAFKA-12879: Revert changes from KAFKA-12339 and instead add retry capability to KafkaBasedLog#11797
rhauch merged 29 commits into
apache:trunkfrom
philipnee:kafka-12879-connect

Conversation

@philipnee

@philipnee philipnee commented Feb 23, 2022

Copy link
Copy Markdown
Contributor

Summary
Fixes the compatibility issue regarding KAFKA-12879 by reverting the changes to the admin client from KAFKA-12339 (#10152), and instead perform the retries within the KafkaBasedLog via a new TopicAdmin.retryEndOffsets(..). This method will delegate to the existing TopicAdmin.endOffsets(...) and will retry on RetriableException until the retries (max retries) is hit, or until a specified timeout.

This change should be backward compatible to the KAFKA-12339.

Notable changes are:
Reverted KAFKA-12339

TopicAdmin
Added new retryEndOffsets(...) method that utilizes the new RetryUtil to list end offsets for a set of topic partitions and perform retries upon any RetriableException (including UnknownTopicOrPartitionException, TimeoutException).

KafkaBasdLog
During startup calls TopicAdmin.retryEndOffsets(...) to read end offsets for the log topic and retries if the topic is not available (or any RetriableException).

RetryUtil
A general utility that takes a Callable function, the total duration to retry (may be 0), and backoff time in ms, and that calls the function at least once, and performs retries using the parameters when the function throws RetriableException (e.g. UnknownTopicOrPartitionException, TimeoutException)

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@rhauch rhauch changed the title Added retry capability to TopicAdmin.endOffsets KAFKA-12879: Revert changes from KAFKA-12339 and instead add retry capability to KafkaBasedLog Feb 24, 2022

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @philipnee. I have a few comments below, but otherwise this PR is pretty close.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @philipnee. I have a few more minor comments below.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
- javaDoc
- better logging

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks again, @philipnee. Getting to very nitty details now, but I think if all of these are addressed then we should be good.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated
- Updated documentation
- Updated log message in the retry util, now getting ```[2022-02-25 13:18:34,313] WARN RetriableException caught on attempt 1, retrying automatically up to 9 more times. Reason: timeout exception (org.apache.kafka.connect.util.RetryUtil:62)
org.apache.kafka.common.errors.TimeoutException: timeout exception```
- Improved RetryUtil logic: no retry if maxRetries = 0, no extra sleep for the last retry attempt
- lower case for test methods

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay, just a few more nits related to your recent changes.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/RetryUtilTest.java Outdated
philipnee and others added 2 commits February 25, 2022 14:07
- minors
…tryUtil.java


accepting comments on spacing

Co-authored-by: Randall Hauch <rhauch@gmail.com>

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @philipnee. A few more nits below, but one bigger suggestion around how we know how long to retry. I know I originally suggested the approach in this PR, but I do think my suggested changes are going to be much better.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice, @philipnee! A few nits below, but otherwise looks good.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/util/TopicAdminTest.java Outdated

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the update, @philipnee. I have some very nit-picky suggestions around logging and error messages, which IMO are important to get right so that Connect users know very clearly what's happened when looking at logs or errors.

I also found one potential logic bug in the edge case when the remaining time to retry is smaller than the retry backoff time.

I think if we fix these and the build passes, we're good!

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/RetryUtil.java Outdated
philipnee and others added 3 commits March 3, 2022 12:30
Co-authored-by: Randall Hauch <rhauch@gmail.com>

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @philipnee! LGTM.

@ijuma, do you want to double-check the reversion of KAFKA-12339 / #10152?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants