mosaic icon indicating copy to clipboard operation
mosaic copied to clipboard

API: creating an experiment and adding trees to an experiment aren't atomic

Open brachbach opened this issue 6 years ago • 5 comments
trafficstars

If there's a problem with one of the trees that's supposed to be created (in practice, usually an email address for a malicious expert that's not yet in the app), the trees will be created up until that tree, then the tree creation will error, leaving all of the trees created so far around

It would be good if either all of the trees were created, or none

(atomic as in: https://en.wikipedia.org/wiki/ACID#Atomicity)

brachbach avatar Sep 04 '19 19:09 brachbach

BTW I thought I had created this issue a while ago, so may be a duplicate

brachbach avatar Sep 04 '19 19:09 brachbach

Yeah good point would make sense to wrap in a transaction.

zjmiller avatar Sep 04 '19 20:09 zjmiller

Agreed as well. @zjmiller do we have any examples of transactions with atomic guarantees in Mosaic?

andrewschreiber avatar Sep 05 '19 01:09 andrewschreiber

No but in this case with everything limited to a single function body is should be fairly straightforward: https://sequelize.org/master/manual/transactions.html

zjmiller avatar Sep 05 '19 03:09 zjmiller

For changing expert designations, https://github.com/oughtinc/mosaic/pull/701 now uses atomic transactions. I will save atomic transactions on bulkCreateExperiments for a separate PR so 701 doesn't get too large.

andrewschreiber avatar Sep 05 '19 18:09 andrewschreiber