incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrius Juozapaitis <andri...@gmail.com>
Subject how to ensure transactions over multiple documents?
Date Thu, 02 Apr 2009 11:49:45 GMT
Hey,

I think this question might have come up before, but I've not found a
definite solution to the problem. I'm trying to model a simple
shopping cart solution on couchdb, just to find out the solutions to
the problems that have come to my mind so far. Let's say, I have 2
types of documents, products and categories, where product may belong
to multiple categories. I expect product to hold an array of category
ids. A simple use case:
1) user A updates an existing product, and updates a category(-ies),
say, increasing product count property
2) the same category at the same time is being updated by user B, by
uploading an updated image to it

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. What is the common scenario
to solve this type of problems (this is just an example, the actual
application has way more and varied dependencies). I do have an
application server (tomcat+spring) handling all the user interaction
to couchdb through jcouchdb, so I am free to implement any type of
solution in the appserver layer. Any suggestions will be very much
appreciated :)

regards,
Andrius Juozapaitis

Mime
View raw message