The logic today is:
- RPC layer UpdateActor(newActor)
- Get current value from DB
- Check UID precondition
- Use current version as expected version if not specified by user
- Apply changes to in-memory state
- Call storage layer UpdateActor(newActor)
- Open txn
- Get current value from DB
- Check expected version == current version
- Commit
This is ...pretty broken?
Between steps 3 and 7 the DB may have been updated and we are now operating on a totally different object.
We do Get twice.
I think we need to let the storage layer be atomic. To my eyes that looks something like:
- RPC layer UpdateActor(newActor)
- Create a callback
- Call storage layer UpdateActor(newActor, callback)
- Open txn
- Get current value from DB
- Call callback(new, old)
6a) Check UID precondition IFF it was specified
6b) Check version IFF it was specified
6c) Apply changes to in-memory state
- Commit
Am I misunderstanding something?
Julian Gutierrez Oschmann (@juli4n) Luiz Oliveira (@laoj2) Eitan Yarmush (@EItanya)
I am trying to do declarative validation and demonstrate what a "canonically correct" update operation looks like, and this set off all my alarms.
The logic today is:
This is ...pretty broken?
Between steps 3 and 7 the DB may have been updated and we are now operating on a totally different object.
We do
Gettwice.I think we need to let the storage layer be atomic. To my eyes that looks something like:
6a) Check UID precondition IFF it was specified
6b) Check version IFF it was specified
6c) Apply changes to in-memory state
Am I misunderstanding something?
Julian Gutierrez Oschmann (@juli4n) Luiz Oliveira (@laoj2) Eitan Yarmush (@EItanya)
I am trying to do declarative validation and demonstrate what a "canonically correct" update operation looks like, and this set off all my alarms.