go data_error ai_generated true

rpc error: code = Aborted desc = concurrency conflict: version mismatch

ID: go/grpc-aborted-concurrency

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2025-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active — — —

Root Cause

The operation was aborted due to a concurrency conflict, such as an optimistic locking failure where the resource version changed.

generic

中文

由于并发冲突(例如乐观锁失败导致资源版本更改),操作被中止。

Workarounds

  1. 95% success
    for {
        resource, err := client.Get(ctx, &GetRequest{Id: id})
        if err != nil { return err }
        resource.Data = newData
        _, err = client.Update(ctx, resource)
        if status.Code(err) != codes.Aborted {
            return err
        }
        // retry
    }
  2. 90% success
    // Include version in the update request
    req := &UpdateRequest{Id: id, Data: newData, Version: currentVersion}
    _, err := client.Update(ctx, req)
    if status.Code(err) == codes.Aborted {
        // handle conflict
    }

Dead Ends

Common approaches that don't work:

  1. 100% fail

    The version is outdated; retrying with the same version will fail again.

  2. 90% fail

    This can lead to lost updates and data inconsistency.