# rpc error: code = Aborted desc = transaction aborted: concurrent modification detected

- **ID:** `go/grpc-aborted-transaction-rollback`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A transaction was aborted due to a conflict with another concurrent transaction, common in distributed databases.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## Workarounds

1. **Retry the transaction with exponential backoff and jitter.** (85% success)
   ```
   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)
}
   ```
2. **Reduce contention by using smaller transactions or optimistic locking.** (75% success)
   ```
   Design the system to minimize overlapping transactions, e.g., partition data by user ID.
   ```

## Dead Ends

- **Ignore the error and assume partial success.** — The transaction was fully aborted; no changes were applied. (100% fail)
- **Immediately retry without any delay.** — Immediate retry may hit the same conflict again, especially under high contention. (70% fail)
