From user-return-23165-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun Dec 23 10:43:38 2012 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A219E11A for ; Sun, 23 Dec 2012 10:43:37 +0000 (UTC) Received: (qmail 28909 invoked by uid 500); 23 Dec 2012 10:43:36 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 28856 invoked by uid 500); 23 Dec 2012 10:43:35 -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 28816 invoked by uid 99); 23 Dec 2012 10:43:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Dec 2012 10:43:34 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ciprian.craciun@gmail.com designates 209.85.215.170 as permitted sender) Received: from [209.85.215.170] (HELO mail-ea0-f170.google.com) (209.85.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Dec 2012 10:43:26 +0000 Received: by mail-ea0-f170.google.com with SMTP id d11so2477105eaa.1 for ; Sun, 23 Dec 2012 02:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=1CbHxT3IrL0S64AlFQdhw6UX5ldmoHRehI3R4Z6w3WA=; b=AH4LD8o3kQ281NjqnHStIViqmbyjElmKYZQn/RuB7Mip5y74KMmQ4OYUThmo4qwQ2g Ji65vaj+RrprTqVebRtCOB+utpc8YGMViMBGkkWqg/WrakQ4l4EpnK1w3nbuNtE8d80p +8ZE6nvSQp8T9QNNSiGOPSzh3hhOZ83jyoYDYsNZyLMwZHf/Dm439VnXWAn5/A76NSQ1 CWibJw9O3OnGnYFbUTI+zBIjQSmv2VYA0KlZ5SSCJ5//Jxrd4I9evNauOGXfoRpvWVJt z5ORXNbdyjBFy+BKJnaxYRNlXTc0yqhbJ0CjsVcCvZ4EPb5s7cXPu2W2t28WS4oc6h1G riyw== MIME-Version: 1.0 Received: by 10.14.176.66 with SMTP id a42mr47359933eem.34.1356259386291; Sun, 23 Dec 2012 02:43:06 -0800 (PST) Received: by 10.14.129.202 with HTTP; Sun, 23 Dec 2012 02:43:06 -0800 (PST) In-Reply-To: References: <14FC9F1D-8CD8-46B5-BC84-703EEC4128C3@couchbase.com> Date: Sun, 23 Dec 2012 12:43:06 +0200 Message-ID: Subject: Re: Regarding `_bulk_docs` atomicity [Was: Re: How to find the change sequence of a document's revision] From: Ciprian Dorin Craciun To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Sun, Dec 23, 2012 at 12:33 PM, Robert Newson wrote: > The above output confirms that doc1 is not created because doc3 failed > validation. So, this is atomic across the group. But note that this > only applies to validation. If doc3 had not caused the commit to > abort, then doc1 and doc2 would both have been updated as well, even > if this introduces a conflict. > > So, to take this back to the first post in the thread, all_or_nothing > doesn't provide the semantics you need, because it will introduce > conflicts rather than abort. The 0.9 and earlier behavior did provide > the semantics you need. On the contrary, as I've written in my initial email, if the validation is able to abort the entire commit I could do the following "hack" (citing from my first email): ~~~~ * I use "all-or-nothing" mode; * I make a design doc which requires that that the developer puts in a field of the new JSON object, `$prev_rev`, which must be equal with the `_rev` field of the previous document already stored; ~~~~ Shouldn't this work? (To my understanding it should achieve what I want as long as I control both the documents put in and the design document.) But still there is the question of concurrent bulk writes: * are they executed sequentially? * or is the document validation function executed sequentially for the same document? Because if there is a race condition for the same document validation my "hack" won't work... Thanks, Ciprian.