From ba3d23992bd41606eae36fe2f1858d336f3d6699 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 7 Nov 2019 09:49:47 +1100 Subject: Throw away writes in failed Select operations Note there's no test for this yet, afaik, and clearly it's not optimized. It also wasn't the cause of the issue I thought i was seeing, but is more correct. --- funcs.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'funcs.go') diff --git a/funcs.go b/funcs.go index ceb162b..b13a917 100644 --- a/funcs.go +++ b/funcs.go @@ -105,8 +105,14 @@ func Select(fns ...Operation) Operation { case 1: return fns[0](tx) default: + oldWrites := tx.writes + tx.writes = make(map[*Var]interface{}, len(oldWrites)) + for k, v := range oldWrites { + tx.writes[k] = v + } ret, retry := catchRetry(fns[0], tx) if retry { + tx.writes = oldWrites return Select(fns[1:]...)(tx) } else { return ret -- cgit v1.2.3