aboutsummaryrefslogtreecommitdiff
path: root/funcs.go
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-07 09:49:47 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-07 09:49:47 +1100
commitba3d23992bd41606eae36fe2f1858d336f3d6699 (patch)
tree4ef6bb4857ff9c2a3767715eebd022ac7d029030 /funcs.go
parentAdd Tx.String (diff)
downloadstm-ba3d23992bd41606eae36fe2f1858d336f3d6699.tar.gz
stm-ba3d23992bd41606eae36fe2f1858d336f3d6699.tar.xz
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.
Diffstat (limited to 'funcs.go')
-rw-r--r--funcs.go6
1 files changed, 6 insertions, 0 deletions
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