Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 46375 invoked from network); 4 Apr 2009 10:04:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Apr 2009 10:04:57 -0000 Received: (qmail 71050 invoked by uid 500); 4 Apr 2009 10:04:55 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 70964 invoked by uid 500); 4 Apr 2009 10:04:55 -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 70954 invoked by uid 99); 4 Apr 2009 10:04:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Apr 2009 10:04:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of antony.blakey@gmail.com designates 209.85.142.191 as permitted sender) Received: from [209.85.142.191] (HELO ti-out-0910.google.com) (209.85.142.191) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Apr 2009 10:04:46 +0000 Received: by ti-out-0910.google.com with SMTP id u5so1577305tia.3 for ; Sat, 04 Apr 2009 03:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=OVukgZvmj9EVEmMxkSssO8wlN0ePqgAVnYUvQou/UzA=; b=kkmezJtZgvBk5WCUYDCyuNtEZ+IPrnIKPxaYnPMvx5/UFyVV1WCuh4X/dlmeBCCsj0 cGEBSJqO06G2UikjT291sjRxvozczIos/PyXP3mafe53+LzvkH5U8GDnmuCvy4Hi59jq Gimz523cQjQnSl1mzpWMDMqUf+WJZIcrF5UAc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=dRZXLe0IkPqY4C5cfuSYiJMwnJU6z4qCtNA4APOxLys3fRBbCsSLz7jVNZkbKg/qG3 CCNViy5/cyqtsvEhe+f4sIwItRsHbwJWFAPomXONb3BQbDS3+5Kwf5Iz6kWyLP8gneFn wF0vxcxdyZO/EQi81PRbNThSmdtKgdOqx4PsA= Received: by 10.110.16.15 with SMTP id 15mr3178229tip.26.1238839463543; Sat, 04 Apr 2009 03:04:23 -0700 (PDT) Received: from ?192.168.0.20? (ppp121-45-74-2.lns10.adl6.internode.on.net [121.45.74.2]) by mx.google.com with ESMTPS id d7sm288178tib.22.2009.04.04.03.04.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 04 Apr 2009 03:04:22 -0700 (PDT) Message-Id: From: Antony Blakey To: user@couchdb.apache.org In-Reply-To: <49D7206D.7010907@gmx.de> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.4) Subject: Re: how to ensure transactions over multiple documents? Date: Sat, 4 Apr 2009 20:34:17 +1030 References: <49D60586.7090108@timparkin.co.uk> <49D61871.1090608@proven-corporation.com> <49D61D2B.7090600@proven-corporation.com> <49D62252.1050007@timparkin.co.uk> <49D62402.2010904@proven-corporation.com> <49D7206D.7010907@gmx.de> X-Mailer: Apple Mail (2.930.4) X-Virus-Checked: Checked by ClamAV on apache.org On 04/04/2009, at 7:25 PM, Sven Helmberger wrote: >>> Spring allows you to create application-wide singletons, one of >>> which >>> could be the jcouchdb Database object. >>> >>> In order to keep the write serialization more or less transparent to >>> the application developer, I guess >>> 1) I'd write an aspect on top of that bean, that would proxy the >>> update/delete related operations, adding the identity of object >>> operated on to an active object list (exact data structure might >>> vary). >>> 2) Another aspect would handle the bulk insert method; it would >>> check >>> if any of the objects being inserted/updated are already in the >>> active >>> objects list, and if not, add all the inserted object ids to the >>> active object list before update, and removing them afterwards. >>> 3) Operations (update/delete) that affect objects already in active >>> object list would simply throw an exception without even hitting >>> couchdb. >>> >>> Then just serialize the access to that active object list. What do >>> you think? >> You would still get conflict on update unless you serialise all >> access and check the existing rev of all intended updates before >> committing. I'm not sure the active list buys you much - you also >> need to deal with replication updating the db. > > I wonder if there's really a way to handle this in any transparent > way (with or without Spring/AOP). > > To me it seems like a explicit working set you can add stuff to and > that you can finally commit would be most helpful. I'm not sure how > such a thing should work. You can sure add all kinds of documents to > the working set and use bulk update to commit it, but what do you do > when some of the documents conflict? Trying to restore the > conflicting documents' previous revision seems like the best bet, > but even that seems like it can't really work in all cases. I'm going to bet that it's not possible, if for no other reason than the lack of a low level interposition mechanism that covers updates generated by replication. Antony Blakey -------------------------- CTO, Linkuistics Pty Ltd Ph: 0438 840 787 Reflecting on W.H. Auden's contemplation of 'necessary murders' in the Spanish Civil War, George Orwell wrote that such amorality was only really possible, 'if you are the kind of person who is always somewhere else when the trigger is pulled'. -- John Birmingham, "Appeasing Jakarta"