Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CED8D10A2D for ; Thu, 10 Oct 2013 15:53:05 +0000 (UTC) Received: (qmail 23727 invoked by uid 500); 10 Oct 2013 15:53:04 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 23447 invoked by uid 500); 10 Oct 2013 15:53:04 -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 23439 invoked by uid 99); 10 Oct 2013 15:53:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 15:53:03 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jens@couchbase.com designates 206.225.164.28 as permitted sender) Received: from [206.225.164.28] (HELO EXHUB020-1.exch020.serverdata.net) (206.225.164.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 15:52:58 +0000 Received: from EXVMBX020-1.exch020.serverdata.net ([169.254.4.141]) by EXHUB020-1.exch020.serverdata.net ([206.225.164.28]) with mapi; Thu, 10 Oct 2013 08:52:37 -0700 From: Jens Alfke To: "user@couchdb.apache.org" Date: Thu, 10 Oct 2013 08:52:35 -0700 Subject: Documentation of winning-revision algorithm? Thread-Topic: Documentation of winning-revision algorithm? Thread-Index: Ac7F0L3FF/ckEV4nQPuzW4c2Aj5P/g== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Is there any explicit documentation of the algorithm CouchDB uses to pick t= he default =93winning=94 revision of a document that=92s in conflict? The c= losest I could find was in the documentation=92s chapter on conflicts[1], b= ut although it says several times that CouchDB picks a revision as the defa= ult one, it never says how it arrives at it. This isn=92t just an implementation detail, because it explains behavior th= at can seem weird to developers. This came up for me because I got a bug re= port saying that =93deleted documents come back after a pull replication=94= =97 the replication pulled in a conflicting branch in which the document w= asn=92t deleted. The developer filing the bug report knew about conflicts, = but their intuition was that since the local deleted revision was =93deeper= =94 (higher generation number) than the one pulled in, it would still win a= nd the doc would still be deleted. Anyway, my understanding (as implemented in TouchDB/Couchbase Lite) is that= the winning revision is picked by these rules, in descending order of prio= rity: 1. A live revision wins over a deleted one. 2. Higher generation number [the numeric prefix of the revision ID] wins. 3. Lexicographically-higher revision ID wins. Amirite? (I arrived at this after a couple of explanations from Damien, but= I still might have missed something=85) Anyway, it would be nice to add this to the docs somewhere. =97Jens [1] http://docs.couchdb.org/en/latest/replication/conflicts.html=