dagobah icon indicating copy to clipboard operation
dagobah copied to clipboard

Enforce consistency in writes

Open thieman opened this issue 11 years ago • 0 comments

A somewhat prerequisite for #77.

Currently, Dagobah's consistency model is basically last write wins with very little effort made towards ensuring a client has the latest version of the object it's trying to update. This is what we want to move towards:

  1. Client A loads Job A. This comes with a vector clock or something that indicates the version of Job A that Client A knows about.
  2. Client B loads Job A with the same vector clock.
  3. Client B posts an update to Job A, providing the vector clock as a parameter to the update. The server verifies that the vector clock matches the current version of Job A, then processes the update. Job A gets a new vector clock on the server, which is passed back to Client B as a response to its request.
  4. Client A posts an update to Job A with its outdated vector clock. The server knows that Client A is working off of outdated information and refuses to process the update. The server returns a 409 CONFLICT response and the client refreshes its information. The user can then try to process the update again.

This should be simple on the server side since we're single-threaded and synchronous. Vector clocks are probably overkill for this, a simple version number might suffice.

thieman avatar May 29 '14 19:05 thieman