mozilla / mentat

UNMAINTAINED A persistent, relational store inspired by Datomic and DataScript.
https://mozilla.github.io/mentat/
Apache License 2.0
1.65k stars 115 forks source link

Implement `db.fn/cas` for compare-and-set semantics #596

Open rnewman opened 6 years ago

rnewman commented 6 years ago

https://docs.datomic.com/on-prem/transactions.html#dbfn-cas

ncalexan commented 6 years ago

I thought about this at one point, and concluded that the best way to implement this was a post checker that verifies the CAS conditions after doing the searches against existing data, but before committing the transaction.

rnewman commented 6 years ago

Aye, that's feasible. But it does mean introducing some error state in InProgress — if the transaction aborts then we need to get back up the stack and block the InProgress, not just the SQL transaction.