dagobah
dagobah copied to clipboard
Enforce consistency in writes
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:
- 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.
- Client B loads Job A with the same vector clock.
- 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.
- 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.