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 0951C9C96 for ; Wed, 28 Dec 2011 03:37:57 +0000 (UTC) Received: (qmail 83669 invoked by uid 500); 28 Dec 2011 03:37:56 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 83629 invoked by uid 500); 28 Dec 2011 03:37:55 -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 83607 invoked by uid 99); 28 Dec 2011 03:37:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2011 03:37:52 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2011 03:37:45 +0000 Received: by vbbfk1 with SMTP id fk1so12523333vbb.11 for ; Tue, 27 Dec 2011 19:37:24 -0800 (PST) Received: by 10.52.94.97 with SMTP id db1mr15329333vdb.16.1325043444195; Tue, 27 Dec 2011 19:37:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.199.198 with HTTP; Tue, 27 Dec 2011 19:37:02 -0800 (PST) In-Reply-To: References: <2073127356.24602.1324243590757.JavaMail.tomcat@hel.zones.apache.org> <1765975633.44958.1324877790680.JavaMail.tomcat@hel.zones.apache.org> From: Jason Smith Date: Wed, 28 Dec 2011 10:37:02 +0700 Message-ID: Subject: Re: [jira] [Commented] (COUCHDB-1367) When settings revs_limit on db - the db increases its update_seq counter when viewing stats - but not when getting changes To: dev@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Wed, Dec 28, 2011 at 9:38 AM, Randall Leeds wrote: > On Tue, Dec 27, 2011 at 05:22, Jason Smith wrote: >> On Tue, Dec 27, 2011 at 5:04 AM, Randall Leeds wrote: >>> Either >>> these things have a proper place in the sequential history of a >>> database or they do not. That there are things which affect update_seq >>> but do not appear in the by_seq index and _changes feed feels like a >>> mistake. >> >> The first sentence is, well, a tautology actually, but it asks the >> right question and the answer is they DO NOT belong. _changes shows >> data, not metadata. By definition, _changes is anything worth >> replicating. > > That strikes me as incorrect. The _changes feed is purely metadata > unless ?include_docs=true is specified. Yes, "data" and "metadata" are problematic words. I'll stop using them. Do you agree that _changes is, by definition, anything worth replicating? >> But I hope my filesystem example above shows why it is okay to >> increment update_seq but not change by_seq. > > You show a nice precedent for separating metadata and data, but > CouchDB has a decent precedent of avoiding this same thing. For > example, _id and _rev are in the returned document body rather than > part of the HTTP request (it could have been just URL and entity tag > headers only for this). Yeah that's a good point. >> The bug with update_seq is not that it it is too eager (increments for >> _security, _revs_limit), but it is not eager enough (it should bump >> for _local too). >> > > I agree, but for different reasons. I think _local docs may have a > place in by_seq even if the default _changes request still only shows > the default, replicable documents. That's an interesting idea. IMO, _security, _revs_limit, apply to a specific database and URL, and consequently must never replicate. _local docs are those which don't replicate. If _local would replicate, I'd worry about spurious checkpoints spreading to where they don't belong; and unchecked _security replication is even worse. Your idea improves consistency and orthogonality. It also solves the problem of how to enumerate _local docs. (AFAIK there is no way to list them all, not via _all_docs, or _changes, or a view). But it doesn't solve the larger problem: How to follow a _changes feed and know when you have caught up. Both Bob N. and I independently did the following for our projects: 1. GET /db and wrongly assume update_seq will appear in the changes feed 2. GET /db/_changes?feed=continuous 3. Break when a change has .seq >= update_seq Suppose you have step 0: Update _security or _revs_limit. The loop will never break. You propose (WLOG) _changes?comprehensive=true which guarantees a change equal or greater than update_seq. That's cool, but IMO app developers now have to add code to ignore irrelevant changes like those containing replication checkpoints. I propose (WLOG) update_sikh in the db header which is the seq id of the latest *document* update. App developers modify their step 1 to use update_sikh instead of update_seq. Is that an accurate synopsis? >> 2. As a frequent consumer of _changes, I would prefer *not* to see >> _local documents, nor _security or other updates in there. They are >> metadata, not data. Maybe I misunderstood, but nobody wants to >> *replicate* _security objects or _local docs; they just want MVCC >> semantics (Adam on _security, IIRC) and a simplified API (me, on >> making all metadata a _local doc, and making _local docs full MVCC). > > I think you misunderstand, maybe. In the case of BigCouch, MVCC is all > that's needed because the replication does not go over HTTP. I see no > reason to require that special care be taken to copy these objects > when a flag on the _changes feed might cause them to be transferred > very naturally. In particular, I would use this feature in a > hypothetical Lounge 3.0. It also means that with admin privileges we > could do full backup replications. If couch could do this, then cool. But consider that both examples are the same special-case: sharding and simulating a normal database API when there are actually multiple parts. That sounds like an application concern. Is it really true that shards need the same _revs_limit as the simulated whole? Maybe they really want _revs_limit / number_of_shards? Is it really necessary that _security be identical in each shard? Actually, yes it is, because validate_doc_update uses it. But still... How are you computing doc_count in the /db response? You have to sum doc_count from each shard. But every shard needs a copy of every design doc for validation. So you have to subtract those back out? My broader point is, sharding applications already do lots of magic. I'm not sure if replicating _security and _local docs buys you much. But you've definitely persuaded me that your idea works. It is the second-best proposal I've seen in this thread :) -- Iris Couch