googleapis / googleapis/google-cloud-java

[java-storage] Update blob metadata conflict throws a non-retryable StorageException

未关闭
#12,630 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
api: storage
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
157

描述

#### Description

I'm updating the metadata of a blob. When concurrent updates are done, a StorageException is thrown as expected, mentioning a conflict. However, the exception is marked as non-retryable, while the exception message prompts to try again, which is contradictory.
I'd expect the exception to be retryable in that case.

#### Environment details

Using google-cloud-storage 2.52.3 and kotlin 2.0.0

#### Steps to reproduce

1. Try updating the metadata of a blob in 2 concurrent processes

#### Code example

```kotlin
storage
.get(blobId)
.toBuilder()
.setMetadata(
mapOf(
"MyKey" to "MyValue"
)
).build()
.update()
```

#### Stack trace
```
com.google.cloud.storage.StorageException: The metadata for object "path/to/my/blob" was edited during the operation. Please try again.
at com.google.cloud.storage.StorageException.translate(StorageException.java:230)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:360)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.patch(HttpStorageRpc.java:719)
at com.google.cloud.storage.StorageImpl.lambda$update$19(StorageImpl.java:609)
at com.google.cloud.storage.Retrying$DefaultRetrier.run(Retrying.java:165)
at com.google.cloud.storage.Retrying$HttpRetrier.run(Retrying.java:206)
at com.google.cloud.storage.StorageImpl.run(StorageImpl.java:1619)
at com.google.cloud.storage.StorageImpl.update(StorageImpl.java:607)
at com.google.cloud.storage.Blob.update(Blob.java:865)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 409 Conflict
POST https://storage.googleapis.com/storage/v1/b/my-bucket/o/path%2Fto%2Fmy%2Fblob?projection=full
{
"code" : 409,
"errors" : [ {
"domain" : "global",
"message" : "The metadata for object \"path/to/my/blob\" was edited during the operation. Please try again.",
"reason" : "conflict"
} ],
"message" : "The metadata for object \"path/to/my/blob\" was edited during the operation. Please try again."
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$3.interceptResponse(AbstractGoogleClientRequest.java:479)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:565)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:506)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:616)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.patch(HttpStorageRpc.java:716)
... 28 common frames omitted
```

Following these steps guarantees the quickest resolution possible.

Thanks!

贡献指南

打开贡献指南

调研方向

先阅读 StorageException.java 中 translate 附近的代码,然后按照 stack trace 所示,通过 HttpStorageRpc.java 和 StorageImpl.java 跟踪 409 冲突。如果该冲突能够根据其提示调用方重试的消息,被一致地归类为可重试,并且在现有测试暴露出该路径时为其补充回归覆盖,则视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
gcp, google-cloud, java
领域
api, cloud
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。