()
| 189 | } |
| 190 | |
| 191 | func (txn *txnLeasing) serverTxn() (*v3.TxnResponse, error) { |
| 192 | if err := txn.lkv.waitSession(txn.ctx); err != nil { |
| 193 | return nil, err |
| 194 | } |
| 195 | |
| 196 | userOps := gatherOps(append(txn.opst, txn.opse...)) |
| 197 | userTxn := v3.OpTxn(txn.cs, txn.opst, txn.opse) |
| 198 | fbOps := txn.fallback(userOps) |
| 199 | |
| 200 | defer closeAll(txn.lkv.leases.LockWriteOps(userOps)) |
| 201 | for { |
| 202 | cmps, err := txn.guard(userOps) |
| 203 | if err != nil { |
| 204 | return nil, err |
| 205 | } |
| 206 | resp, err := txn.lkv.kv.Txn(txn.ctx).If(cmps...).Then(userTxn).Else(fbOps...).Commit() |
| 207 | if err != nil { |
| 208 | for _, cmp := range cmps { |
| 209 | txn.lkv.leases.Evict(strings.TrimPrefix(string(cmp.Key), txn.lkv.pfx)) |
| 210 | } |
| 211 | return nil, err |
| 212 | } |
| 213 | if resp.Succeeded { |
| 214 | txn.commitToCache((*v3pb.TxnResponse)(resp), userTxn) |
| 215 | userResp := resp.Responses[0].GetResponseTxn() |
| 216 | userResp.Header = resp.Header |
| 217 | return (*v3.TxnResponse)(userResp), nil |
| 218 | } |
| 219 | if err := txn.revokeFallback(resp.Responses); err != nil { |
| 220 | return nil, err |
| 221 | } |
| 222 | } |
| 223 | } |
no test coverage detected