Skip to content
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

client: reset backoff to 0 after a connection is established #2669

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ func (ac *addrConn) resetTransport() {
continue
}

backoffFor = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

It works fine for us to reconnect immediately after connection closed.
But I think this also resets backoff duration when reconnecting failed repeated in the server down, which resulted in trying to reconnect aggressively.

So the backoff duration should be reset only in first retry like this?

if ac.backoffIdx == 0 {
	backoffFor = 0
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If reconnecting failed, we will continue above, and won't reach this.
This only happens when we successfully create a connection, and we want to skip any backoff if this connection breaks.

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry it's my bad. I tried again with this branch and it does retry to connect with backoff correctly.

Copy link
Member

@dfawley dfawley Mar 7, 2019

Choose a reason for hiding this comment

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

Actually, this should also reset ac.backoffIdx = 0.

EDIT: Oh we already do this below; maybe we should move it up here though for consistency and to avoid taking the lock an extra time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have cleanup changes in another branch, was trying to keep this change simple so we can cherrypick it to previous releases.

ac.mu.Lock()
ac.curAddr = addr
ac.transport = newTr
Expand Down