Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 89042 invoked from network); 18 Nov 2010 00:15:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 18 Nov 2010 00:15:58 -0000 Received: (qmail 9976 invoked by uid 500); 18 Nov 2010 00:16:28 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 9883 invoked by uid 500); 18 Nov 2010 00:16:28 -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 9875 invoked by uid 99); 18 Nov 2010 00:16:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Nov 2010 00:16:28 +0000 X-ASF-Spam-Status: No, hits=2.9 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [74.125.82.180] (HELO mail-wy0-f180.google.com) (74.125.82.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Nov 2010 00:16:23 +0000 Received: by wya21 with SMTP id 21so2576936wya.11 for ; Wed, 17 Nov 2010 16:15:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.239.200 with SMTP id c50mr2359407wer.63.1290039358054; Wed, 17 Nov 2010 16:15:58 -0800 (PST) Received: by 10.216.71.139 with HTTP; Wed, 17 Nov 2010 16:15:58 -0800 (PST) In-Reply-To: References: <4ce418b2.096ee60a.57dd.7e17@mx.google.com> <23543823-7536-4620-AB61-A3AC8BAA43B8@apache.org> Date: Wed, 17 Nov 2010 19:15:58 -0500 Message-ID: Subject: Re: Write race conditions, working without _rev From: Chad George To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=e0cb4e385666aee0b7049548b1eb --e0cb4e385666aee0b7049548b1eb Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I've been wondering about this for a while, when two update requests for th= e same document come to couchdb nearly simultaneously what exactly happens? Is it possible for both requests to get the same revision of the document t= o update or is there some mechanism to force the updates to occur in series? - chad On Wed, Nov 17, 2010 at 1:51 PM, Paul Davis wr= ote: > On Wed, Nov 17, 2010 at 1:49 PM, Jan Lehnardt wrote: > > > > On 17 Nov 2010, at 19:24, Paul Davis wrote: > > > >> On Wed, Nov 17, 2010 at 1:02 PM, rpkeane@gmail.com > wrote: > >>> > >>> > >>> Sent from my HTC on the Now Network from Sprint! > >>> > >>> ----- Reply message ----- > >>> From: "Luciano Ramalho" > >>> Date: Sat, Nov 6, 2010 15:52 > >>> Subject: Write race conditions, working without _rev > >>> To: > >>> > >>> On Fri, Nov 5, 2010 at 2:03 PM, Paul Davis < > paul.joseph.davis@gmail.com> wrote: > >>>> In the second case, the second person to write the document wins, > >>>> erasing any changes the first write's effects. The first writer will > >>>> then be in a state where his view of the database will be > >>>> inconsistent. The thing his, he can't know because without requiring= a > >>>> _rev token he'll never get a notification of any sort of error. > >>> > >>> As I understand, the situation you describe above never happens in > >>> practice with CouchDB. A second PUT to the same document _id will > >>> always require the _rev attribute, so there's no way to overwrite a > >>> previous update by accident. This is one of the best features of > >>> CouchDB for document-oriented persistency. > >>> > >>> > >>> -- > >>> Luciano Ramalho > >>> programador repentista || stand-up programmer > >>> Twitter: @luciano > >>> > >> > >> That's true if you don't use _update handlers to hack around that part > >> of CouchDB's design. > > > > Update handlers can't bypass the rev check, they only take the decision > > closer to the database. With two concurrent update functions, one will > > fail and one will win. > > > > Cheers > > Jan > > -- > > > > > > Touch=E9. Jan is quite right, that two simultaneous _update handlers > that try and write the incomming doc with the current doc's _rev tag > could still fail. They just make the window smaller as they're closer > to the db. > > Paul > --e0cb4e385666aee0b7049548b1eb--