Repository navigation
Back off between reconnect attempts that get no session - #23
Open
atsarevskiy wants to merge 1 commit into
Open
atsarevskiy wants to merge 1 commit into
atsarevskiy wants to merge 1 commit into
Conversation
- Wait 100 ms before the second attempt, doubling up to 2 s, also when retry_time is 0. - Reset the delay when a session is established. Fixes krojew#21
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #21.
When a server accepts the TCP connection and then closes it, or refuses the connection, the client reconnects at once, for as long as the server keeps doing that.
Each attempt logs about five lines.
Cause
Connection closed: readand callsreconnect()with no delay(io.rs#L538-L544).
reconnect()waitsretry_timeonly when the TCP connect fails(io.rs#L355-L363),
and
ZooKeeper::connectsetsretry_timeto 0(zookeeper.rs#L115).
Fix
reconnect()waits before every attempt after the first one that didn't get a session: 100 ms, doubling up to 2 s.The delay applies when
retry_timeis 0 too; a configuredretry_timestill adds to it after a failed TCP connect.Tests
tests/test_reconnect_backoff.rs: a local server accepts and closes every connection, and the test requires 2 to 10 connections in 3 s.On master it fails with 14,256 connections; with this change the client made 5.
cargo test --all-featureswithzk-test-clusterbuilt: 25 passed on master, 26 passed with this change.cargo fmt --checkpasses;cargo clippy --all-targets --all-featuresreports the same 9 warnings as master.Zk session timeoutwarning still prints on every attempt while the client has no session, becauseping_sentonly moves when a ping is sent.