couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Marshall <omarsh...@facilityone.com>
Subject Re: Resolving a classical conflict in CouchDB - Looking for best practices / advise
Date Fri, 20 May 2011 14:19:44 GMT
On 05/20/2011 09:46 AM, Oren Shani wrote:
> The problem is that if I have to applications calling the function
> concurrently, it might end up with a conflict, and then the document in
> the database will have for example keyhash["abcd"] =5 /or
> /keyhsah["efgh"] = 5 instead of keyhash["abcd"] = 5 /and/
> keyhash["efgh"] = 6 (this is a rather classical concurrency conflict
> problem so I suppose you understand what I mean...)

GET your document with conflicts=true. If there are any conflicting
revisions, GET those revisions as well. Then just merge together in a
single document, write that correct document, and delete the conflicting
revisions. I use a single POST to _bulk_docs for that part.

See:
http://wiki.apache.org/couchdb/Replication_and_conflicts

-- 
Owen Marshall
FacilityONE
http://www.facilityone.com | (502) 805-2126


Mime
View raw message