-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add 503 to list of retriable HTTP response codes #1232
Comments
As you pointed out, 503 and connection errors are considered retryable in the python client. However, retries are only enabled by default for uploads if the upload is confirmed to be idempotent - that is by including request preconditions The retry strategy is outlined in https://cloud.google.com/storage/docs/retry-strategy#python. This docs go into detail about which operations are conditionally idempotent, retryable exceptions and client retry config options. Here is a sample code that demonstrates adding the generation match precondition to an upload. In your code sample, assuming the upload is for a new file, set
|
Hi @cojenco thank you for your fast response. My reading of python-storage/google/cloud/storage/blob.py Lines 2827 to 2841 in ae9a53b
python-storage/google/cloud/storage/retry.py Lines 141 to 143 in ae9a53b
Therefore, I am referring to the Have I misunderstood something?
No, our use case is to successfully upload new or overwrite existing files, so I don't believe that having a precondition on the generation being zero is going to comprehensively assist in this case, if I understand correctly? |
Hi @andrewpollock thanks for the follow-up.
Your understanding in (1) and (2) are accurate. However, to clarify your following point:
python-storage/google/cloud/storage/retry.py Lines 45 to 61 in ae9a53b
Given your use case has a mix of new and existing objects, a few options worth considering:
(b) adjust the retry strategy to always retry retryable errors
Setting Please let me know if this doesn't answer your question. |
Thank you. Today, I'm wondering if this is an "and" versus "or" misunderstanding on my behalf, with respect to (2)?
This was my point. Based on the behaviour I'm reporting here and in #1231 it doesn't appear to be the case? But maybe it's because of my misunderstanding as per above? |
As per suggestion here googleapis/python-storage#1232 (comment)
Environment details
Python 3.11.4
pip 23.1.2 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
google-cloud-storage
version:2.14.0
Steps to reproduce
Blob.upload_from_filename()
seems to sometimes encounter a 503 responsepython-storage/google/cloud/storage/retry.py
Lines 28 to 38 in ae9a53b
api_exceptions.ServiceUnavailable
is a 503 and should be retried.Code example
https://github.com/google/osv.dev/blob/b705d0d0b7450ce94137624118a2b54a7f719147/docker/exporter/exporter.py#L57-L64
Stack trace
Perhaps 503 needs to be added to
_ADDITIONAL_RETRYABLE_STATUS_CODES
also?The text was updated successfully, but these errors were encountered: