Skip to content

Updates (UpdateActor in particular) are not atomic #815

Description

@thockin

The logic today is:

  1. RPC layer UpdateActor(newActor)
  2. Get current value from DB
  3. Check UID precondition
  4. Use current version as expected version if not specified by user
  5. Apply changes to in-memory state
  6. Call storage layer UpdateActor(newActor)
  7. Open txn
  8. Get current value from DB
  9. Check expected version == current version
  10. 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:

  1. RPC layer UpdateActor(newActor)
  2. Create a callback
  3. Call storage layer UpdateActor(newActor, callback)
  4. Open txn
  5. Get current value from DB
  6. 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
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions