-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spanner: Retry aborted partitioned dml transactions #5412
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
Spanner: Retry aborted partitioned dml transactions #5412
Conversation
| paramsBuilder.putFields(param.getKey(), param.getValue().toProto()); | ||
| builder.putParamTypes(param.getKey(), param.getValue().getType().toProto()); | ||
| com.google.spanner.v1.ResultSet resultSet; | ||
| while (true) { |
There was a problem hiding this comment.
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;
}
}
There was a problem hiding this comment.
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 Report
@@ 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 8638Continue to review full report at Codecov.
|
2e2a226 to
bc1f933
Compare
Fixes #5410