couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Blakey <>
Subject Re: how to ensure transactions over multiple documents?
Date Sat, 04 Apr 2009 10:04:17 GMT

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"

View raw message