谷歌云存储随机503错误在PATCH



我有一个代码,它从bucket中读取文件,然后编辑所有文件元数据中的content_encoding。它通常工作得很好,但自从3天前我在谷歌存储API上遇到问题以来,它似乎随机返回503个错误。我已经尝试过使用一个600秒截止日期的重试策略,但代码仍然返回错误。

我在一个带有9.1 LTS(包括Apache Spark 3.1.2和Scala 2.12(集群的databricks笔记本中用python3运行这段代码。

google-cloud-srtorage API版本->2.5.0

我读了一些关于这个问题的旧帖子,它似乎是一个已知的问题,但我仍然无法解决它

def blob_list(bucket_name):
try:
client = storage.Client()
blobs = client.list_blobs(bucket_name)
print('Bucket read')
return blobs
except Exception as e:
print('Counld not read the bucket', e)

b = blob_list(bucket_name)
count = 0
modified_retry = DEFAULT_RETRY.with_deadline(600)
modified_retry = modified_retry.with_delay(initial=1.5, multiplier=1.2, maximum=45.0)
for item in b:
CS = storage.Client()
blob = CS.bucket(bucket_name).blob(item.name)
blob.patch(retry=modified_retry)
#  print(blob.content_encoding)
if blob.content_encoding == 'gzip' or blob.content_encoding == 'txt': 
blob.content_encoding = 'csv'
blob.patch(retry=modified_retry)
count +=1
print('Changed',count,'metadata files')

代码运行时间过长,仍在抛出此错误

调用目标函数时超过了600.0s的截止时间,最后一个异常:503 PATCHhttps://storage.googleapis.com/storage/v1/b/bucket_name/o/yof0soyd7668_2022-08-15T060000_06db87dcb5e5ee06ec13ab5fbefe4df0_be822a.csv.gz?projection=full&prettyPrint=false:我们遇到一个内部错误。请再试一次。

错误似乎发生在patch((方法中。

不幸的是,这是谷歌方面的一个问题。我在2年多以来每天运行的流程中遇到了和你一样的503错误。我通过GCP创建了一个支持案例,正在等待回复。

相关内容

最新更新