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

Using a retry with back off for auth refreshing. #504

Merged
merged 1 commit into from
Oct 12, 2015

Conversation

sduskis
Copy link
Contributor

@sduskis sduskis commented Oct 9, 2015

The Credential retrieval has occassional issues under load. Dataflow, for example, will start a whole bunch of jobs that need to get credentials at the same time, and we've seen intermittent failures because of that issue; the retry should fix, or at least improve, those types of situations.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 9, 2015
@derjust
Copy link
Contributor

derjust commented Oct 9, 2015

Sounds like awesome!
This scenario we saw for sure and any kind of improvment is highly welcome

}


protected HeaderCacheElement refreshCredentialsWithRetry(BackOff backoff) {
Copy link
Contributor

Choose a reason for hiding this comment

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

private HeaderCacheElement refreshCredentialsWithRetry(@nullable BackOff backoff) {

Can you document this?

@kevinsi4508
Copy link
Contributor

I have no problem retrying getting credentials on IOException. If this is intended to fix issue: #475, we need to make sure retrying will actually help.

protected boolean sleepOrTerminate(BackOff backoff) {
long nextBackOffMillis = 0;
try {
nextBackOffMillis = backoff.nextBackOffMillis();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can clean this up a bit:
long nextBackOffMillis = backoff.nextBackOffMillis();
if (nextBackOffMillis == BackOff.STOP) {
return true;
}
try { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nextBackOffMillis() throws the exception. It's needs to be within the try.

@@ -60,7 +48,7 @@ public void sleep(long ms) throws InterruptedException {
@VisibleForTesting
BackOff currentBackoff;
@VisibleForTesting
Sleeper sleeper = THREAD_SLEEPER;
Sleeper sleeper = Sleeper.THREAD_SLEEPER;
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this Sleeper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

public interface Sleeper {
void sleep(long ms) throws InterruptedException;

static Sleeper THREAD_SLEEPER = new Sleeper() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

  • private constructor
  • static Sleeper 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.

Since we want multiple implementations for test purposes, INSTANCE seems less informative than THREAD_SLEEPER. Maybe DEFAULT_INSTANCE.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is a nit. It is up to you.

@kevinsi4508
Copy link
Contributor

LGTM, some nits

@sduskis sduskis force-pushed the retry_auth branch 3 times, most recently from 538923f to 5ae164f Compare October 9, 2015 21:25
The Credential retrieval has occassional issues under load.  Dataflow, for example, will start a whole bunch of jobs that need to get credentials at the same time, and we've seen intermittent failures because of that issue; the retry should fix, or at least improve, those types of situations.

Adding a unit test for retry logic in the auth interceptor.

Updating the Test as per Kevin's comments.

Adding more logging around credential refreshes and retries.

Using an explicit start time for the tests in RefreshingOAuth2CredentialsInterceptorTest.
sduskis added a commit that referenced this pull request Oct 12, 2015
Using a retry with back off for auth refreshing.
@sduskis sduskis merged commit 967ecce into googleapis:master Oct 12, 2015
@sduskis sduskis deleted the retry_auth branch October 26, 2015 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants