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 E0860703A for ; Thu, 25 Aug 2011 03:31:14 +0000 (UTC) Received: (qmail 11529 invoked by uid 500); 25 Aug 2011 03:31:13 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 10275 invoked by uid 500); 25 Aug 2011 03:31:01 -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 10261 invoked by uid 99); 25 Aug 2011 03:30:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Aug 2011 03:30:54 +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 (athena.apache.org: local policy) Received: from [209.85.160.180] (HELO mail-gy0-f180.google.com) (209.85.160.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Aug 2011 03:30:48 +0000 Received: by gyc15 with SMTP id 15so2020917gyc.11 for ; Wed, 24 Aug 2011 20:30:27 -0700 (PDT) Received: by 10.231.75.99 with SMTP id x35mr11720239ibj.50.1314243027091; Wed, 24 Aug 2011 20:30:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.174.194 with HTTP; Wed, 24 Aug 2011 20:30:07 -0700 (PDT) In-Reply-To: References: From: Jason Smith Date: Thu, 25 Aug 2011 10:30:07 +0700 Message-ID: Subject: Re: Our views keep failing with timeouts until a couchdb restart To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 On Thu, Aug 25, 2011 at 9:55 AM, Paul Davis wrote: >> 1. CouchDB has an odd, idiosyncratic, feature where GET queries >> produce side-effects. From HTTP, there are no side-effects, but as you >> can see, GETting a view can spawn couches processes and write files to >> the disk. Perhaps you could add ?stale=ok to all of your queries used >> in production. To my knowledge, stale=ok guarantees that couchjs will >> not be involved in servicing that query. This protects your users from >> seeing map/reduce errors. The down-side is that you must of course >> query the views yourself to keep them current. >> > > No, couchjs will still be required to service reductions. stale=ok > just means you don't have to wait for a possibly lengthy view build. Thanks for the correction. > Also, "GET's cause side effects" is a bit misleading I think. A GET on > a view by default tries to return data from something equal to or > newer than the current database update_seq. If the current view state > hasn't caught up to the db's update_seq it waits. Classifying this as > "GET's have side effects" is really like saying "GET to a Rails APP > causes side effects because you have to wait for the template to > render." > > For those familiar with internals its quite true that if the indexer > isn't running, a new GET request will trigger an update. But say we > change that so that view updates are tried every N seconds and a GET > itself will never trigger an update but might endure a delay of N-1 > seconds before anything starts happening. You'd be hard pressed to say > that the "GET caused side effects" in that case yet the observable > behavior is the same: "sometimes it takes a while." Yes, I use a sloppy definition. Every query has side effects, since they are logged. But that is a trivial case. So you are right. At any rate, for all the system administrator knows, a GET query can create a new .view file and build a 500GB view which fills up the disk. It's a small detail worth knowing. Day-to-day, it's not that serious of a threat. The main point is that you get more robust and more predictable behavior by using ?stale=ok most of the time, and taking the trouble to update the views independently. In my projects, I have a change count and also time duration threshold. If either are exceeded then it triggers a view refresh on all design documents for that database. -- Iris Couch