# rpc 错误：code = Aborted desc = 检测到并发修改

- **ID:** `go/grpc-aborted-concurrent-modification`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器检测到并发修改冲突，通常由于乐观锁或事务冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   for i := 0; i < 5; i++ {
    resp, err := client.YourMethod(ctx, req)
    if err == nil { break }
    if status.Code(err) == codes.Aborted {
        time.Sleep(time.Duration(1<<i) * time.Second)
        continue
    }
    return err
}
   ```
2. **** (85% 成功率)
   ```
   // Include a version field in your request and have the server check it.
// On conflict, fetch the latest version and retry.
   ```

## 无效尝试

- **** — Immediate retries can exacerbate contention and lead to more conflicts. (80% 失败率)
- **** — Disabling concurrency control can lead to data corruption and is not acceptable. (95% 失败率)
