Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 26955 invoked from network); 6 Apr 2011 00:46:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Apr 2011 00:46:27 -0000 Received: (qmail 48769 invoked by uid 500); 6 Apr 2011 00:46:26 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 48674 invoked by uid 500); 6 Apr 2011 00:46:26 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 48666 invoked by uid 99); 6 Apr 2011 00:46:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Apr 2011 00:46:26 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ryan.ramage@gmail.com designates 74.125.82.180 as permitted sender) Received: from [74.125.82.180] (HELO mail-wy0-f180.google.com) (74.125.82.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Apr 2011 00:46:18 +0000 Received: by wyj26 with SMTP id 26so1224103wyj.11 for ; Tue, 05 Apr 2011 17:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=1Q3deEHdqyKkTQCL4PUxbnuM0KwzZcgYmO9h/VQqFBc=; b=liHQhju09bHUn9qbhERjQwpoFENywXTw1IjFma1NsQy2hfphmWdf7Z13R3X+3FVZlF znWyFeSm54DVOgqfPI6AgkX5Tk7piROGVnD9WrX8+t+e13zAz5DzLDJIfqaEKNkeKsxI 0yrNc+QokA+HCJU5Hpamepbt+8O1sStTDMeVA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=oGtal2OsqOJ7PaR1IWtynT1VWCgt+qFRXk0yK80Pnbp8vtYhP5kHDW8KH5GCAj7D6u eR+izxAYLyuxUn0E6JGZe1iejyMIHYdpyhz8NzuxU6kbUZgK7hl2XRNcK8fa/7JuvD6i 4VwDo82/1cZmIHu2TJZr3A4orB1xdXdDnbjx4= MIME-Version: 1.0 Received: by 10.227.110.147 with SMTP id n19mr329580wbp.51.1302050757982; Tue, 05 Apr 2011 17:45:57 -0700 (PDT) Received: by 10.227.152.141 with HTTP; Tue, 5 Apr 2011 17:45:57 -0700 (PDT) In-Reply-To: References: Date: Tue, 5 Apr 2011 18:45:57 -0600 Message-ID: Subject: Re: Update conflicts? From: Ryan Ramage To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Luis, Having the rev is very important when you update a doc. It lets you know that your piece of information is out of date. This is a good thing.... I am wondering if the way you are modeling your data is not leading you to do this update with less chance of conflict. See if you can break your docs into even smaller docs. For example, I noticed from a prior post you had a lot of Arrays in your docs. If multiple processes are changing that array, you might be better served by making each element in the array a separate doc. Ryan On Tue, Apr 5, 2011 at 4:41 PM, Luis Miguel Silva wrote: > More or less! > > The most common scenario will be: > - two or more processes writing to the same document, but only to a > specific attribute (not overwriting the whole document) > > If, by any chance, two processes overwrite the same field, i'm ok with > the last one always winning. > > Thanks, > Luis > > On Tue, Apr 5, 2011 at 4:26 PM, Robert Newson wrote: >> "Ideally, we would be able to update without specifying the _rev, just >> posting (or, in this case PUTting) to the document..." >> >> So you want to blindly overwrite some unknown data? >> >> B. >> >> On 5 April 2011 22:57, Zachary Zolton wrote: >>> Luis, >>> >>> Checkout _update handlers: >>> >>> http://wiki.apache.org/couchdb/Document_Update_Handlers >>> >>> >>> Cheers, >>> >>> Zach >>> >>> On Tue, Apr 5, 2011 at 4:46 PM, Luis Miguel Silva >>> wrote: >>>> Dear all, >>>> >>>> I'm trying to play around with updates and i'm bumping into some problems. >>>> >>>> Let's image we have to clients that poll a document from the server at >>>> the same time and get the same _rev. >>>> Then one of them updates the doc based on the _rev it got: >>>> [root@xkitten ~]# curl -X PUT -d >>>> '{"_rev":"3-0d519bcf08130bf784f3c35d79760740","hello2":"fred2"}' >>>> http://localhost:5984/benchmark/test?conflicts=true >>>> {"ok":true,"id":"test","rev":"4-03640ebafbb4fcaf127844671f8e2de7"} >>>> Then another one tries to update the doc based on the same exact _rev: >>>> [root@xkitten ~]# curl -X PUT -d >>>> '{"_rev":"3-0d519bcf08130bf784f3c35d79760740","hello3":"fred3"}' >>>> http://localhost:5984/benchmark/test?conflicts=true >>>> {"error":"conflict","reason":"Document update conflict."} >>>> [root@xkitten ~]# >>>> >>>> Is there a way to avoid this?! (like...make the update just create a >>>> new _rev or something)?? >>>> >>>> Ideally, we would be able to update without specifying the _rev, just >>>> posting (or, in this case PUTting) to the document... >>>> >>>> Thoughts?? >>>> >>>> Thank you, >>>> Luis >>>> >>> >> >