-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[WIP] Spanner - Use gax for runWithRetries() #4781
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
Conversation
Clean up SpannerImpl by moving inner classes to separate files and group these into logical units.
Codecov Report
@@ Coverage Diff @@
## master #4781 +/- ##
============================================
+ Coverage 49.44% 50.07% +0.63%
- Complexity 21501 22813 +1312
============================================
Files 2168 2168
Lines 212334 216773 +4439
Branches 23409 24263 +854
============================================
+ Hits 104987 108548 +3561
- Misses 99134 99882 +748
- Partials 8213 8343 +130
Continue to review full report at Codecov.
|
| @@ -0,0 +1,213 @@ | |||
| /* | |||
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.
are these chances part of the overall refactoring?
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.
Yes, this class used to be an inner class of SpannerImpl. I based this change on the branch of the refactor PR, as they would otherwise cause a lot of merge conflicts between the two of them.
If you only want to see the changes made after the overall refactoring, you can use this link: olavloite/google-cloud-java@spanner-refactor-spannerimpl...olavloite:spanner-gax-retry
The most important change is in SpannerImpl.java. The other changes are changes that are necessary as the new retry method is not static, as gax uses the ServiceOptions that have been used to create the Spanner instance.
|
@olavloite ApiFuture returned by callable do support cancellation of calls. Also with every call to callable, we can provide call context with deadline. I think whole of retrying logic can be migrated to gax and configured in handwritten client. |
@ajaaym Yes, I agree with you on that, but as far as I can see we will be changing the behavior for users that currently set a deadline or cancellation themselves. Consider the code in Or am I missing something here? |
|
Replaced by #4940 |
Instead of using its own retry logic, SpannerImpl should use the retry helper and options from gax.
This PR is based on #4749 Spanner refactor spannerimpl, which should be processed first.
Issues / discussion:
SpannerImpl already uses
io.grpc.Contextto enable setting timeouts and cancelling database operations. This will interfere with using the functionality from gax. The implementation in this PR supports both, but the behavior is different from the previous version if the user for example sets a short timeout onContextin combination with a longer timeout onRetrySettings. If the timeout ofRetrySettingsis longer than the timeout set onContext, the context timeout will only occur after the timeout ofRetrySettingshas occurred (i.e. the time before the timeout exception is thrown is longer than the user would have expected).Possible solutions as I see them at this moment:
io.grpc.Contextfor setting timeouts and cancelling database operations, and only rely on the functionality from gax (which use theRetrySettings). This would change the behavior for clients who currently use this to set a timeout or to cancel calls.io.grpc.Contextif one is set (or if the current context is a CancellableContext), and use gax in all other cases. This basically means 'use the current functionality if the user has set a deadline on the Context or indicated that it should be cancellable, and useRetrySettingsin all other cases'.