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

Support for configuring exponential connection backoff params #2735

Closed
wants to merge 6 commits into from

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Apr 2, 2019

Support for backoff params as defined in https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
fixes #2724

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
CLA GitHub bot

@easwars
Copy link
Contributor Author

easwars commented Apr 2, 2019

Hmm ... I've signed the CLA now as an individual and as an employee. Not sure if this gets updated automatically.

Update fork with changes from master
@easwars easwars self-assigned this Apr 9, 2019
@easwars easwars requested a review from dfawley April 10, 2019 16:40
@dfawley dfawley assigned dfawley and unassigned easwars Apr 11, 2019
backoff.go Outdated Show resolved Hide resolved
backoff.go Outdated
// failure.
BaseDelay time.Duration
// Multiplier is the factor with which to multiply backoffs after a failed
// retry.
Copy link
Member

Choose a reason for hiding this comment

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

Any bounds on this? I.e. must be > 0? (Or > 1?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment saying it should be ideally greater than 1. Should we have validation code for that or more explicit warnings that if the user sets it to less than 1, they are shooting themselves in the foot?

backoff.go Outdated Show resolved Hide resolved
type Strategy interface {
// Backoff returns the amount of time to wait before the next retry given
// the number of consecutive failures.
Backoff(retries int) time.Duration
// MinConnectionTimeout returns the minimum amount of time we are willing to
// give a connection to complete.
MinConnectionTimeout() time.Duration
Copy link
Member

Choose a reason for hiding this comment

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

MinConnectTimeout is not a function of backoff, so it doesn't really belong in this package. I think we can keep MCT separate from backoff strategy and store them separately in the ClientConn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it from here.
Added it as a field in dialOptions with defaultDialOptions() setting the existing default value for this. Overrides are done from WithConnectParams(), which feels a little odd to me, but thought I will run it by you anyways.

// baseDelay is the amount of time to wait before retrying after the first
// StrategyBuilder helps build an implementation of the Strategy interface,
// with setters provided to set individual parameters of the backoff strategy.
type StrategyBuilder interface {
Copy link
Member

Choose a reason for hiding this comment

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

This is not very Go-idiomatic. Why not export the fields in Exponential and set them directly? This is an internal package, so we can do whatever we want with it w.r.t. changing how the defaults are applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if the fields of Exponential are exposed, we can directly set them from WithConnectParams() where all fields are expected.
But in places where only a subset of the fields are to be modified and the rest should continue to have their default values (especially for other internal packages), this is much easier to use. Also, it makes it easier to allow setting any of the fields to their zero value.

Move MinConnectionTimeout() out of backoff.Strategy interface. Store
it directly in dialOptions instead, and have ClientConn use it from
there.
@easwars
Copy link
Contributor Author

easwars commented Apr 12, 2019

PTAL.

@easwars
Copy link
Contributor Author

easwars commented May 14, 2019

This was the first PR that I sent, and I had sent this out of my master branch (just poor git skills). And now this is turning out to be pain as I create new branches to work on other things. So, I'm going to close this, and will send out a fresh one from a new branch. Thanks.

@easwars easwars closed this May 14, 2019
@dfawley
Copy link
Member

dfawley commented May 14, 2019

Note that there is nothing special about your "master" branch. It's the same as any other branch. You just needed to create a different branch in your fork based off grpc's master. Something like this (there may be even better ways, but this is the limit of my git knowledge):

git fetch upstream master
git checkout upstream/master
git checkout -b newmaster # or featurex etc

@dfawley
Copy link
Member

dfawley commented May 14, 2019

(Also sorry for the delays in reviewing.)

easwars added a commit to easwars/grpc-go that referenced this pull request May 14, 2019
I need to roll these back because I had sent out changes from my master
branch, and this is causing a lot of pain right now for my work on other
branches. I will create a branch for this issue and will send out these
changes in a fresh PR.
@euroelessar
Copy link

Thank you!

easwars added a commit to easwars/grpc-go that referenced this pull request Aug 6, 2019
I need to roll these back because I had sent out changes from my master
branch, and this is causing a lot of pain right now for my work on other
branches. I will create a branch for this issue and will send out these
changes in a fresh PR.
easwars added a commit to easwars/grpc-go that referenced this pull request Aug 6, 2019
I need to roll these back because I had sent out changes from my master
branch, and this is causing a lot of pain right now for my work on other
branches. I will create a branch for this issue and will send out these
changes in a fresh PR.
@lock lock bot locked as resolved and limited conversation to collaborators Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More parameters for exponential connection backoff
4 participants