Skip to content

Commit

Permalink
Reduce time spent backing off dry run query (#33888)
Browse files Browse the repository at this point in the history
* Reduce time spent backing off dry run query

* Fix variable usage
  • Loading branch information
damccorm authored Feb 6, 2025
1 parent 222ad95 commit d7cf969
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,22 @@ public JobStatistics dryRunQuery(
new Job()
.setJobReference(jobRef)
.setConfiguration(new JobConfiguration().setQuery(queryConfig).setDryRun(true));
// Use a custom backoff to avoid blocking job submission on being able to do a dry run.
int maxRetries = 5;
BackOff backoff =
BackOffAdapter.toGcpBackOff(
FluentBackoff.DEFAULT
.withMaxRetries(maxRetries)
.withInitialBackoff(INITIAL_JOB_STATUS_POLL_BACKOFF)
.withMaxBackoff(Duration.standardMinutes(1))
.backoff());
return executeWithRetries(
client.jobs().insert(projectId, job).setPrettyPrint(false),
String.format(
"Unable to dry run query: %s, aborting after %d retries.",
queryConfig, MAX_RPC_RETRIES),
queryConfig, maxRetries),
Sleeper.DEFAULT,
createDefaultBackoff(),
backoff,
ALWAYS_RETRY)
.getStatistics();
}
Expand Down

0 comments on commit d7cf969

Please sign in to comment.