Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 16993 invoked from network); 13 Nov 2008 17:44:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Nov 2008 17:44:40 -0000 Received: (qmail 43293 invoked by uid 500); 13 Nov 2008 17:44:46 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 43185 invoked by uid 500); 13 Nov 2008 17:44:46 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 43174 invoked by uid 99); 13 Nov 2008 17:44:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 09:44:46 -0800 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 74.125.46.156 is neither permitted nor denied by domain of ayende@ayende.com) Received: from [74.125.46.156] (HELO yw-out-1718.google.com) (74.125.46.156) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 17:43:23 +0000 Received: by yw-out-1718.google.com with SMTP id 5so451587ywr.0 for ; Thu, 13 Nov 2008 09:44:05 -0800 (PST) Received: by 10.142.71.16 with SMTP id t16mr3802227wfa.273.1226598245153; Thu, 13 Nov 2008 09:44:05 -0800 (PST) Received: by 10.142.177.17 with HTTP; Thu, 13 Nov 2008 09:44:05 -0800 (PST) Message-ID: <27d8d0930811130944n1af5f45bs4c4cfe3fc563b724@mail.gmail.com> Date: Thu, 13 Nov 2008 19:44:05 +0200 From: "Ayende Rahien" To: couchdb-user@incubator.apache.org Subject: Re: dirty reads - update strategies In-Reply-To: <242E1551-4B7E-426D-A60B-FBCA3BEE1FA1@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_25566_28390265.1226598245141" References: <242E1551-4B7E-426D-A60B-FBCA3BEE1FA1@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_25566_28390265.1226598245141 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline This is a hack, but you could use bulk_docs to do this, which would fail if a or b were updated already.This would cause other items (that uses a or b but not change them) to fail updating. On Thu, Nov 13, 2008 at 7:01 PM, ara howard wrote: > > what are people's strategies for dealing with the following scenario > > doc_a = get 'id_a' > > doc_b = get 'id_b' > > obj_c = { 'sum' : doc_a.x + doc_b.y } > > put obj_c > > > this kind of thing is tricky even in a traditional RDBMS, since the default > transaction level may or may not allow the application to see an uncommitted > write by another transaction. > > the only way i can think of to get consistency from an op like the above > would be to do > > bulk_put [ obj_c, doc_a, doc_b ] > > in other words, if you are ever going to compute values to from couch docs > to produce another doc, it would seem that's it's required to put *all* read > information back in order to ensure that the sources have not changed since > the time that you read them. the issue with this, of course, is that a > result computed from many documents is going to cause exponential slowdown > since the potential for overlapping writes will increase with the number of > documents and also the size of updates themselves will increase similarly. > > a solution i can image is something like > > list = get 'some_view' > > obj = computed_value_from list > > obj[ '_depends_on' ] = list.map{|element| [element.id, element.rev]} > > put obj > > > so basically a method to do a put with not only your rev, but that of 'n' > dependent docs where only the [id, rev] pair for the dependent docs need be > posted. am i making any sense here? > > cheers. > > > > a @ http://codeforpeople.com/ > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > ------=_Part_25566_28390265.1226598245141--