Skip to content

Commit

Permalink
Merge pull request etcd-io#6804 from heyitsanthony/stm-conflict
Browse files Browse the repository at this point in the history
grpcproxy: invalidate comparison keys after txn
  • Loading branch information
Anthony Romano authored Nov 5, 2016
2 parents 476ff67 + bf08a61 commit 352d4fa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion proxy/grpcproxy/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ func (p *kvProxy) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, e
}

resp, err := txn.If(cmps...).Then(thenops...).Else(elseops...).Commit()
return (*pb.TxnResponse)(resp), err

if err != nil {
return nil, err
}
// txn may claim an outdated key is updated; be safe and invalidate
for _, cmp := range r.Compare {
p.cache.Invalidate(cmp.Key, nil)
}
return (*pb.TxnResponse)(resp), nil
}

func (p *kvProxy) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
Expand Down

0 comments on commit 352d4fa

Please sign in to comment.