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

Introduce exponentially increasing delay after each join attempt #68

Merged
merged 1 commit into from Jan 22, 2016

Conversation

jwolski
Copy link
Contributor

@jwolski jwolski commented Jan 13, 2016

This PR adds a delay in between each join attempt. The delay is a calculation of an exponential backoff with added jitter/fuzz. The maximum potential delay will increase until it is capped at its max. The actual delay will be a random number between the last used max and the new max. Therefore, after the first join attempt, the delay will be between 0 and 100. On the second attempt, 100 and 200. On the third attempt, between 200 and 400 and so on.

cc @uber/ringpop

@@ -74,21 +74,20 @@ func (s *BootstrapTestSuite) TestBootstrapJoinsTimeOut() {
}

func (s *BootstrapTestSuite) TestBootstrapDestroy() {
var lerr lError
errChan := make(chan error)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTES TO REVIEWER: Don't mind these changes. I cherry-picked a commit from #67 so that these tests pass. I'll delete this commit from this PR when that PR is merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that #67 is merged can we undo this from this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course. i will take care of it.

@jwolski jwolski force-pushed the join-backoff branch 13 times, most recently from 5f85d33 to 8bc79ab Compare January 19, 2016 10:34
defaultMax = float64(60 * time.Second)
)

var defaultRandomizer = rand.Intn
Copy link
Contributor

Choose a reason for hiding this comment

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

this randomizer uses the default source that has deterministic behavior. Lets make our own Rand with a newly seeded Source. To prevent interference with the Source of the application we are embedded in -that application might rely on the fact that random numbers are deterministic- and at the same time prevent all ringpops to use the same 'random' timeouts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a little bit more complicated then that. join_sender.go calls rand.Seed() and I was relying on that as the defaultRandomizer's seed. But that's non-obvious and error prone. I'll move the call to Seed() to the delayer itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought, I'll leave the call to Seed() in join_sender.go and create a new instance of type Rand with its own source.

@thanodnl
Copy link
Contributor

lgtm

}

// nullDelayer is an empty implementation of joinDelayer.
type nullDelayer struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the nullDelayer crammed in between the exponentialDelayer initializer and method?

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 don't know. I'll move it and make it a bit more organized.

@CorgiMan
Copy link
Contributor

Tests are failing :(

@jwolski jwolski force-pushed the join-backoff branch 2 times, most recently from c72c272 to f57dbf9 Compare January 20, 2016 14:51
@CorgiMan
Copy link
Contributor

Looks good!

jwolski pushed a commit that referenced this pull request Jan 22, 2016
Introduce exponentially increasing delay after each join attempt
@jwolski jwolski merged commit a948bbc into master Jan 22, 2016
@jwolski jwolski deleted the join-backoff branch January 22, 2016 09:07
@jwolski jwolski mentioned this pull request Feb 9, 2016
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.

None yet

3 participants