Em-Ant / fcc-options-app

Options Inc. web app development
Other
12 stars 7 forks source link

Concurrency issues #16

Closed andrealonzo closed 8 years ago

andrealonzo commented 8 years ago

When 2 people are logged in and making changes in the app, the changes between the users will not be in sync. This will need to inaccurate states. Here are our proposed solutions:

  1. Leave as-is Trust that the users know that only one person can use the system at a time.
  2. Only have 1 user logged in at a time NOT POSSIBLE If someone is currently logged in, another user cannot log in
  3. Allow only write access to one user The latest logged in user will have write access
  4. Implement version control If the underlying state has changed, notify the user to reload the page. This is similar to version control such as Git.
  5. Concurrent operations between users Users can see updates between users in real time. This is similar to Trello or google docs.
Em-Ant commented 8 years ago

Avoiding the majority of db inconsistencies with edfb1f4. Unfortunately this cannot save the db from being in inconsistent state if concurrent actions happen at the same time, because requires 2 operations (not atomic). But even version control would require atomic operations.

andrealonzo commented 8 years ago

Here is a video on how facebook handle concurrency if someone tries to edit a post that has been deleted. When the user clicks save on the edit screen, a box appears saying:

This content is no longer available The content you requested cannot be displayed right now. It may be temporarily unavailable, the link you clicked on may have expired, or you may not have permission to view this page.

Facebook doesn't refresh the page showing that the post was deleted.

http://screencast.com/t/W7hqtnaH

andrealonzo commented 8 years ago

We could follow facebook's model. This would mean that for every write request, we need to check if all the references in the request are still available and valid, otherwise the request should fail, and user should know that something failed.