go
runtime_error
ai_generated
true
rpc error: code = Aborted desc = transaction aborted: concurrent modification detected
ID: go/grpc-aborted-transaction-rollback
80%Fix Rate
83%Confidence
0Evidence
2024-11-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0 | active | — | — | — |
| 1.1 | active | — | — | — |
Root Cause
A transaction was aborted due to a conflict with another concurrent transaction, common in distributed databases.
generic中文
事务因与另一个并发事务冲突而中止,常见于分布式数据库。
Workarounds
-
85% success Retry the transaction with exponential backoff and jitter.
for i := 0; i < 5; i++ { err := client.Transaction(ctx, req) if err == nil { return nil } if status.Code(err) != codes.Aborted { return err } time.Sleep(time.Duration(100*(1<<i)) * time.Millisecond) } -
75% success Reduce contention by using smaller transactions or optimistic locking.
Design the system to minimize overlapping transactions, e.g., partition data by user ID.
Dead Ends
Common approaches that don't work:
-
Ignore the error and assume partial success.
100% fail
The transaction was fully aborted; no changes were applied.
-
Immediately retry without any delay.
70% fail
Immediate retry may hit the same conflict again, especially under high contention.