couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Couchdb Wiki] Update of "Transaction model use cases" by AndriusJuozapaitis
Date Thu, 09 Apr 2009 12:17:09 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by AndriusJuozapaitis:

   2. the same category at the same time is being updated by user B, by uploading an updated
image to it
  '''''You shouldn't have a categories count that gets manually updates. Instead, create a
"products by category view" and use a reduction to count the number of each category. -Damien'''''
+ '''''I do realize that I can rework the model in this specific scenario. Maybe it's a bad
example as is... -Andrius'''''
  If the operations happen in this exact order (1,2), user B will get a concurrent modification
warning, and will have to reapply his changes.
  But what if the product gets updated, then the category gets updated with a new image, and
then the product count is increased on that category? The last step will fail, and the data
in the system will remain in (logically) inconsistent state.
+ ==Alright, an even simpler example involving money==
+ documents Account A (1000$), Account B (1000$), with balance property.
+ 2 operations in progress:
+ 1. Transfer 100$ from A to B
+ 2. Deposit 50$ to B
+ 1. A-100$, balance = 900$
+ 2. B+50$, balance = 1050$
+ 3. B+100$, update fails because B's revision is not the one being expected. Balance A(900),
B(1050), 100$ short.

View raw message