-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Adding retry logic to services in google-cloud-python #2694
Comments
That would be great, because retrying would also solve #2699 [logging] |
@dhermes @daspecster To follow up on our offline discussion:
|
Another consideration is that we should have something for the REST implementations that we have. AFAICT GAPIC is only for gRPC right? |
@daspecster Yes, GAPIC currently supports gRPC only. But for whatever you build for REST, it would be ideal to keep it compatible with the GAPIC retry model so that if we "switch out the plumbing" at at later date and support gRPC for those APIs, you won't have to change the surface or duplicate GAPIC functionality. |
#2583 is also relevant to the retry discussion; as we still cannot properly determine which datastore requests to retry, perhaps it can be covered here. |
#2896 affects me as well, end of the stack trace I get is attached to that ticket. |
@geigerj What bugs are retried by default? (Looking at an internal bug where Datastore connections time out after 30 minutes, and auto-retry does not work.) |
Assuming by "bugs" you mean status codes, by default we retry only on However, that configuration can be overridden at a per-service level (example: Pubsub). It would be useful to know what status code Datastore is returning with the 30min timeout; we can add that to the GAPIC config in that case. |
Now that tenacity is a dependency of google-cloud-core, it should be significantly easier to build in consistent retires for all libraries. |
From my point of view the retry logic should be simple and build just into the core, something like "retry when HTTP 5xx". Otherwise it will be hard to make it consistent across Python, Go, PHP, Java, C#, ... or a custom HTTP code. I understand it's not possible always, but the main logic should be in the core and the libraries should cover just some edge cases. We use Python ( |
@xmedeko I'm not sure what you mean. Our libraries do not share a common core across languages. We have to implement retry in each language's core library. |
Maybe I have misunderstood your post "it should be significantly easier to build in consistent retires for all libraries". I would expect the retry logic is just in the I understand there is not a shared core across languages libs. My concern is, that there should be share same logic (rules, principles) across languages libs. I have found different HTTP/JSON request retry logic when I have investigated it a half year ago. |
I am closing this as @jonparrott is already working on retry as part of his google.api.core work. |
Hello,
I cannot throughly test this because I cannot generate 5xx errors, but I think this could help. |
Thank you for the work. We also should have a new retry framework in the api_core module in most (if not all) updated versions. |
Cool, I am looking forward for the retry framework. Just an update: As I commented before, I've tried patching the client with relative success: it works for any request that uses the My next candidate is I found that it would be just too much work to pin down and patch how requests are made internally on the Blob object. I managed to just wrap the only place where I am uploading files around a function that is decorated with a retry library, as my previous post. |
The retry framework is nice, but it would be nicer if it were a bit more configurable. Many of the defaults are less than ideal. To change datastore retry options, I currently monkey patch as follows:
|
@speedplane unless you need to overwrite the defaults for all methods, I don't think you need to do that. Each method should allow you to pass in a |
Yes, but at least in my project, this library is buried under multiple layers of middleware libraries, touching all of the calls is not so straightforward. Using global or a set config file would be nice. In the meantime I can just monkey-patch. |
For instance, the datastore client doesn’t have a configurable retry parameter (https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/datastore/google/cloud/datastore/client.py) and I have further libraries that sit on top of that. |
IMO it's nice to have a possibility to change the default value for all calls. I also increase default retries. (For the old |
After reading this tread I'm still confused on how to fix this problem. Is there a config / parameter where to set the "Retry Strategy"? or other issue where is discussed? |
I ended up doing the same thing as @xmedeko, passing the subclass of class MyHttpRequest(googleapiclient.http.HttpRequest):
def execute(self, http=None, num_retries=20):
return super().execute(http=http, num_retries=num_retries)
creds = ...
sheets = googleapiclient.discovery.build('sheets', 'v4', credentials=creds, requestBuilder=MyHttpRequest) |
I will see if I can find it, but I think there was a thread somewhere that @tseaver and @dhermes were talking about having retry be an option that you passed into the call to the service.
I think some of the other libraries just retry by default but I'll try and dig a little bit.
Issues involving retry:
The text was updated successfully, but these errors were encountered: