Closed yohann84L closed 4 months ago
I'm also seeing the same issue, when are are uploading files within a cloud composer task instance.
Thanks for the question. The python client library can retry ConnectionError
, IF the request is made to be idempotent by including request preconditions. Are you using preconditions for the uploads?
In GCS uploads are conditionally idempotent, that is, they are only safe to retry with a precondition. Could you try including the precondition if_generation_match
to your upload requests?
In your code sample, assuming the upload is for a new file, set if_generation_match=0
to enable retries
blob.upload_from_file(image.file, if_generation_match=0)
Here is a sample code that demonstrates adding the generation match precondition to an upload. The retry strategy is outlined in https://cloud.google.com/storage/docs/retry-strategy#python. This docs go into detail about retryable exceptions, client retry config options, and which operations are conditionally idempotent.
Hope this was helpful. Please open a new issue if you have further questions.
We are encountering a
ConnectionError
while using the cloud storage library in our application. It happens quite rarely 1 to 5 times per month on +20k requests.Environment details
3.8.18
24.0
google-cloud-storage
version:2.16.0
Steps to reproduce
The error occurs during the execution of an API endpoint responsible for uploading images or files to Google Cloud Storage.
Code example
Nothing particular, just a simple:
Stack trace
The function I use:
We appreciate any insights or suggestions on how to resolve this issue.
Thank you!