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

fix: add retry logging for BigQueryRetryAlgorithm.java #1506

Merged
merged 5 commits into from Aug 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -27,7 +27,10 @@
import com.google.api.gax.retrying.TimedRetryAlgorithmWithContext;
import java.util.Iterator;
import java.util.concurrent.CancellationException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.threeten.bp.Duration;

public class BigQueryRetryAlgorithm<ResponseT> extends RetryAlgorithm<ResponseT> {
private final BigQueryRetryConfig bigQueryRetryConfig;
Expand All @@ -36,6 +39,8 @@ public class BigQueryRetryAlgorithm<ResponseT> extends RetryAlgorithm<ResponseT>
private final ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithmWithContext;
private final TimedRetryAlgorithmWithContext timedAlgorithmWithContext;

private static final Logger LOG = Logger.getLogger(BigQueryRetryAlgorithm.class.getName());

public BigQueryRetryAlgorithm(
ResultRetryAlgorithm<ResponseT> resultAlgorithm,
TimedRetryAlgorithm timedAlgorithm,
Expand All @@ -55,6 +60,22 @@ public boolean shouldRetry(
ResponseT previousResponse,
TimedAttemptSettings nextAttemptSettings)
throws CancellationException {
// Log retry info
int attemptCount = nextAttemptSettings == null ? 0 : nextAttemptSettings.getAttemptCount();
Duration retryDelay =
nextAttemptSettings == null ? Duration.ZERO : nextAttemptSettings.getRetryDelay();

if (LOG.isLoggable(Level.FINEST)) {
LOG.log(
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
Level.FINEST,
"Retrying with:\n{0}\n{1}\n{2}",
new Object[] {
"BigQuery attemptCount: " + attemptCount,
"BigQuery delay: " + retryDelay,
"BigQuery retriableException: " + previousThrowable
});
}

// Implementing shouldRetryBasedOnBigQueryRetryConfig so that we can retry exceptions based on
// the exception messages
return (shouldRetryBasedOnResult(context, previousThrowable, previousResponse)
Expand Down