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

Pulsar Clients: Added a mandatory stop to the Backoff logic #747

Merged
merged 6 commits into from
Sep 13, 2017

Conversation

jai1
Copy link
Contributor

@jai1 jai1 commented Sep 7, 2017

}

TimeDuration Backoff::next() {
TimeDuration current = next_;
next_ = std::min(next_ * 2, max_);

static TimeDuration timeElapsedSinceDisconnection_;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not working:

  1. Backoff has no notion of disconnection.. it's just a simple class to deal with exponential backoff
  2. static here is messing up across different Backoff instances. Each connection is having its own instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rookie Mistake :-(

@jai1
Copy link
Contributor Author

jai1 commented Sep 8, 2017

retest this please

@jai1 jai1 force-pushed the Backoff_new_approach branch from ff3fb5b to c4b321f Compare September 11, 2017 06:58
TimeDuration mandatoryStop_;
TimeDuration timeElapsedSinceDisconnection_;
bool mandatoryStopMade_;
unsigned int seed_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to randomSeed_ ?

current = std::max(initial_, mandatoryStop_ - timeElapsedSinceDisconnection_);
mandatoryStopMade_ = true;
}
timeElapsedSinceDisconnection_ += current;
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that the exact current time might be slightly different than the "sleep" time, I think we should be better use an absolute time instead of timeElapsedSinceDisconnection_. That will be resistent to the multiple timeout being scheduled.

Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

👍

@jai1
Copy link
Contributor Author

jai1 commented Sep 13, 2017

retest this please

1 similar comment
@jai1
Copy link
Contributor Author

jai1 commented Sep 13, 2017

retest this please

@jai1 jai1 changed the title CPP Client: Add a mandatory stop to the Backoff logic Pulsar Clients: Added a mandatory stop to the Backoff logic Sep 13, 2017
@merlimat merlimat merged commit 0acfe57 into apache:master Sep 13, 2017
@jai1 jai1 deleted the Backoff_new_approach branch March 19, 2018 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants