Skip to content

Conversation

@olavloite
Copy link

Fixes #5410

@olavloite olavloite requested a review from a team as a code owner June 5, 2019 15:36
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 5, 2019
paramsBuilder.putFields(param.getKey(), param.getValue().toProto());
builder.putParamTypes(param.getKey(), param.getValue().getType().toProto());
com.google.spanner.v1.ResultSet resultSet;
while (true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we avoid these local retry loops and build the txn aborted retry generically into our retry logic ?

there are several other retry codes that probably got deleted with a refactor/change ?

com.google.spanner.v1.ResultSet resultSet =
runWithRetries( // lost this ?
new Callable<com.google.spanner.v1.ResultSet>() {
@OverRide
public com.google.spanner.v1.ResultSet call() throws Exception {
return rpc.executeQuery(builder.build(), session.options);
}
});
These are all the codes we should be retrying on:
private static boolean isRetryable(ErrorCode code, @nullable Throwable cause) {
switch (code) {
case INTERNAL:
return hasCauseMatching(cause, Matchers.isRetryableInternalError);
case UNAVAILABLE:
return true;
case RESOURCE_EXHAUSTED:
return SpannerException.extractRetryDelay(cause) > 0;
default:
return false;
}
}

Copy link
Author

Choose a reason for hiding this comment

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

The above mentioned method was removed during the refactor to use Gax for retries. Retries of single gRPC calls are now automatically handled and retried by Gax (i.e. an rpc call that temporarily returns UNAVAILABLE will automatically be retried by Gax without the need for any custom code in the Spanner library).

Transaction retries are still handled by custom loops in the Spanner library, as these need to retry application logic and possibly multiple gRPC calls. We could refactor these to use the standard Gax com.google.cloud.RetryHelper instead of our own custom retry loops. I've changed this PR for PDML to use the RetryHelper.

I'll submit a separate PR for using RetryHelper for normal transaction retries.

@codecov
Copy link

codecov bot commented Jun 6, 2019

Codecov Report

Merging #5412 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #5412   +/-   ##
=========================================
  Coverage     50.86%   50.86%           
  Complexity    24192    24192           
=========================================
  Files          2270     2270           
  Lines        230115   230115           
  Branches      25009    25009           
=========================================
  Hits         117041   117041           
  Misses       104436   104436           
  Partials       8638     8638

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dae28cb...bc1f933. Read the comment docs.

@olavloite olavloite requested a review from snehashah16 June 6, 2019 16:01
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jun 12, 2019
@olavloite olavloite force-pushed the spanner-retry-aborted-for-pdml branch from 2e2a226 to bc1f933 Compare June 21, 2019 07:49
@kolea2 kolea2 merged commit 6197bb5 into googleapis:master Jun 24, 2019
@JesseLovelace JesseLovelace mentioned this pull request Jun 26, 2019
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. 🚨 This issue needs some love.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry on Transaction Aborted Errors for Partitioned DML

5 participants