go
data_error
ai_generated
true
rpc error: code = AlreadyExists desc = resource already exists: id=123
ID: go/grpc-already-exists-duplicate
80%Fix Rate
88%Confidence
0Evidence
2024-10-12First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.x | active | — | — | — |
Root Cause
The client attempted to create a resource that already exists, often due to a duplicate request or race condition.
generic中文
客户端尝试创建已存在的资源,通常是由于重复请求或竞态条件。
Workarounds
-
90% success
// Client sends a unique idempotency key // Server checks if key already processed if exists, return existing resource else create new
-
85% success
resp, err := client.Create(ctx, req) if status.Code(err) == codes.AlreadyExists { // Fetch existing resource getResp, err := client.Get(ctx, &GetRequest{Id: req.Id}) // use getResp }
Dead Ends
Common approaches that don't work:
-
80% fail
This may violate business logic if the ID is meaningful; also doesn't address the root cause of duplicate requests.
-
70% fail
The operation didn't create a new resource, leading to inconsistent state.