Skip to content

Commit

Permalink
fixup! Improve Log
Browse files Browse the repository at this point in the history
  • Loading branch information
markflyhigh committed Dec 12, 2016
1 parent ba7a8d3 commit 7f11448
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -153,8 +153,11 @@ Bigquery newBigqueryClient(String applicationName) {
QueryResponse queryWithRetries(Bigquery bigqueryClient, QueryRequest queryContent,
Sleeper sleeper, BackOff backOff)
throws IOException, InterruptedException {
IOException lastException;
IOException lastException = null;
do {
if (lastException != null) {
LOG.warn("Retrying query ({}) after exception", queryContent.getQuery(), lastException);
}
try {
QueryResponse response = bigqueryClient.jobs().query(projectId, queryContent).execute();
if (response != null) {
Expand All @@ -165,14 +168,15 @@ QueryResponse queryWithRetries(Bigquery bigqueryClient, QueryRequest queryConten
}
} catch (IOException e) {
// ignore and retry
LOG.warn("Ignore the error and retry the query.");
lastException = e;
}
} while(BackOffUtils.next(sleeper, backOff));

throw new RuntimeException(
String.format(
"Unable to get BigQuery response after retrying %d times.", MAX_QUERY_RETRIES),
"Unable to get BigQuery response after retrying %d times using query (%s)",
MAX_QUERY_RETRIES,
queryContent.getQuery()),
lastException);
}

Expand Down

0 comments on commit 7f11448

Please sign in to comment.