Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 27504 invoked from network); 5 Apr 2009 21:17:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Apr 2009 21:17:19 -0000 Received: (qmail 68893 invoked by uid 500); 5 Apr 2009 21:17:18 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 68802 invoked by uid 500); 5 Apr 2009 21:17:18 -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 68792 invoked by uid 99); 5 Apr 2009 21:17:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2009 21:17:18 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sshumaker@gmail.com designates 209.85.217.162 as permitted sender) Received: from [209.85.217.162] (HELO mail-gx0-f162.google.com) (209.85.217.162) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2009 21:17:11 +0000 Received: by gxk6 with SMTP id 6so4327953gxk.11 for ; Sun, 05 Apr 2009 14:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=rTRP52EeXu4TuQK6uMfkj+487qtP5u4O1kjbWWIt85E=; b=GFGhXSXHWFqG9sSiN7+OHyiGAMq26hGhq3EwrrfGlnjPnSbtBNpwHR9FqxygD1EYYv 7/GGFTseCjPY11Hr742j9Z3NM8CSvkD/C3CFyWUpLSjar1yLLGev+4nizOtcJabErqfA KATBXdMwrkQ4YkAPYBXW9ILUIH4gt0bVxA16g= 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:content-transfer-encoding; b=Hv1ocH832yLq7rdr+a0U8ennZMtaPc7UXW9R/emoYR/4rIZjBAEilJn3Mamusisa0G 0Jm21LBEIS1wfBjmIVIrzo0PC7BdEO7Ycltp+UUDd67xwzsKaGn9d/tkkOJQLKoD3rMM dbUKk3o3eaDprqavpB371gbjhO0gi67j3iy9A= MIME-Version: 1.0 Received: by 10.150.206.1 with SMTP id d1mr7049998ybg.6.1238966210771; Sun, 05 Apr 2009 14:16:50 -0700 (PDT) In-Reply-To: References: <49D61D2B.7090600@proven-corporation.com> <49D62252.1050007@timparkin.co.uk> <49D62402.2010904@proven-corporation.com> <49D7206D.7010907@gmx.de> Date: Sun, 5 Apr 2009 14:16:50 -0700 Message-ID: <261cf6280904051416j77d7f85eja7c1f4fe96b08ca2@mail.gmail.com> Subject: Re: how to ensure transactions over multiple documents? From: Scott Shumaker To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Cross-posting from dev, since this may be a better forum: How about something like this to implement transactions? During an 'transactional bulk write': - For each document in the transaction, - Attempt to create a new rev of the document, specially flagged so it doesn't show up in views, document fetches, or replications (return the last version of this documents instead). While hidden, There would probably be some way to retrieve them, like the way you retrieve conflicted versions currently. - This rev SHOULD be examined when checking for conflicts with subsequent writes (so no new writes to the document can happen while the transaction is in progress - they return with a conflict error). - If all of the documents in the transaction are created successfully (pass document validation, don't conflict with earlier revs), remove the flags from these revisions (therefore becoming standard revs in the database). If not, remove these newly created revs. This would sort of give a loose form of two-phase commit that should work over sharded databases. There's obviously a higher performance cost - it's equivalent to two writes (once to write these 'shadow' revisions, and once again to remove the flags on success or prune the revisions on failure). And clients won't be able to write to any of the documents in the transaction until it completes (effectively locking them for write), because they won't be able to see the latest version. But it would probably achieve the effect that most people want. And naturally, it wouldn't be the default bulk_write behavior (given the cost and limitations). For Multi-master replication, this really shouldn't change anything. The hidden rev won't replicate to other masters, but if another master attempts to replicate a version over the top of the hidden rev, it's treated exactly the same way as a standard multi-master conflict; it will be flagged as conflicted, and one of them will show up in views. On Sat, Apr 4, 2009 at 4:54 AM, Antony Blakey wro= te: > > On 04/04/2009, at 9:48 PM, Andrius Juozapaitis wrote: > >> Antony: I was assuming (given a replication scenario) that I'll be >> using one node as a =A0master, and spring would only access this node >> for updates, while the others would be used for reading only. > > Certainly for very specific architectures there are workable solutions - > yours being one of them. My goal is to encourage the most general solutio= n > possible, as in my transactional git branch. > > If you eliminate relplication then you can completely wrap CouchDB's API = and > apply both significantly extended and quite different semantics (of cours= e). > In fact, this is how I think the app-server like features of CouchDB shou= ld > be done, rather than the current model. The problem is that CouchDB doesn= 't > expose enough to do that wrapping once replication is involved. > > Antony Blakey > -------------------------- > CTO, Linkuistics Pty Ltd > Ph: 0438 840 787 > > Don't anthropomorphize computers. They hate that. > > >