Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76F36880B for ; Sun, 11 Sep 2011 02:55:00 +0000 (UTC) Received: (qmail 70218 invoked by uid 500); 11 Sep 2011 02:54:59 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 69588 invoked by uid 500); 11 Sep 2011 02:54:49 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 69573 invoked by uid 99); 11 Sep 2011 02:54:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Sep 2011 02:54:47 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of randall.leeds@gmail.com designates 209.85.213.52 as permitted sender) Received: from [209.85.213.52] (HELO mail-yw0-f52.google.com) (209.85.213.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Sep 2011 02:54:40 +0000 Received: by ywp31 with SMTP id 31so1957156ywp.11 for ; Sat, 10 Sep 2011 19:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8wK5Bxbo62To2tKdka02rfQfLze97L3xXsu7rsAyWXw=; b=dJpkJkQgL9fOYezPQJZHnArF7fl7hO7gUlAVmq7YF2cAMgK5FQm50KUZhKQgIKFaap cYb3wECB1ib6xXu/1P4Y0kriRQOtKqnSF5MVN17rchO+xvPb8nQi182Be3GmI9mYkQfl ttk9GtopcdrYKt1gNzBy7BT61hzUoMOcEgSWI= MIME-Version: 1.0 Received: by 10.42.152.70 with SMTP id h6mr65059icw.119.1315709659847; Sat, 10 Sep 2011 19:54:19 -0700 (PDT) Received: by 10.42.226.73 with HTTP; Sat, 10 Sep 2011 19:54:19 -0700 (PDT) In-Reply-To: <04419515-81B2-480D-A897-2BDD4EC8EFD5@yahoo.com> References: <04419515-81B2-480D-A897-2BDD4EC8EFD5@yahoo.com> Date: Sat, 10 Sep 2011 19:54:19 -0700 Message-ID: Subject: Re: [proposal] Update Handler Conflict Resolution From: Randall Leeds To: dev@couchdb.apache.org Content-Type: multipart/alternative; boundary=90e6ba6e8f28e71b9d04aca186bd --90e6ba6e8f28e71b9d04aca186bd Content-Type: text/plain; charset=UTF-8 On Fri, Sep 9, 2011 at 06:37, Pepijn de Vos wrote: > Hi, > > Today I had a long and complicated discussion involving rnewson, jan____, > me and muhqu. > > I was falsely assuming Document Update Handlers did atomic updates. Truth > is that they don't, but for most of my use cases could. > > What currently happens is that the update handler gets executed with the > latest rev of the requested doc. When the update is completed, it is > committed, but when another update has meanwhile happened, a conflict arises > and 409 is returned. > > When I use update handlers, I mostly use idempotent functions. This means > that it is safe for the update handler to retry on its own account, and in > doing so, avoid a ton of latency and headaches. > > Only, it turns out that programmatic updates are not the sole use for > update handlers, so rnewson argued that it might destroy data. > > Proposal 1: > Add an idempotent=true parameter to the handler, allowing it to retry on > its own. > > Proposal 2: > Add an update() function so the handler can handle conflicts in itself. > Just so I understand... is update() a function called from within the handler that tries to commit the result? If this fails, should there be a function to retrieve the latest version of the document again? I sort of like this approach. Proposal 1 makes some sense but I worry about a request potentially being retried 'forever' and not sure how to impose limits on that without expanding our configuration space or HTTP API surface area when proposal 2 is perhaps cleaner. -Randall --90e6ba6e8f28e71b9d04aca186bd--