-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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-6101 Reconnecting to broker does not exponentially backoff #4108
Conversation
retest this please |
Thanks for the PR. Can we please add a test? |
I ran thru NetworkClientTest but the tests didn't exercise the code path I modified. Suggestion on how to emulate the scenario is appreciated. |
None of the clients tests references ClusterConnectionStates.
Some test can assert that the counter is greater than one. But ClusterConnectionStates is not public. |
KafkaProducer doesn't expose getter for Sender. |
@@ -28,6 +30,7 @@ | |||
* | |||
*/ | |||
final class ClusterConnectionStates { | |||
private static final Logger log = LoggerFactory.getLogger(ClusterConnectionStates.class); |
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.
Is there a specific reason for adding this in? I can't find any usages of the logger ..
Ran the following using Java 8 which passed:
|
Hi @tedyu, you are indeed right, there are no tests covering this code, however I'd argue that there should be. I've created some test cases in a pull request to cover the basic workings of this class as I understand it. I've left out a test for the code you fixed for now, as it'd fail anyway. |
Thanks, @soenkeliebau Please give Sönke credit since the test came from him. |
Hi @tedyu - I may have phrased my last comment badly, the test I referenced does not test proper backoff behavior but only the maximum backoff value, to test your code we need a test case that checks for the backoff to be within the proper range for a few reconnect attempts. I've sent you a new pull request with a proposal of how a test case like that could look. |
Rewrote test case to check proper backoff handling (Sönke).
retest this please |
@tedyu, can you please rebase against trunk? Thanks. |
Let me open a new PR. |
For reconnection, share the nodeState if one exists.
Only update its state and lastConnectAttemptMs.