Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 83538 invoked from network); 7 Aug 2010 00:58:11 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Aug 2010 00:58:11 -0000 Received: (qmail 88906 invoked by uid 500); 7 Aug 2010 00:58:10 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 88844 invoked by uid 500); 7 Aug 2010 00:58:09 -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 88836 invoked by uid 99); 7 Aug 2010 00:58:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Aug 2010 00:58:09 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of shasderias@gmail.com designates 209.85.216.52 as permitted sender) Received: from [209.85.216.52] (HELO mail-qw0-f52.google.com) (209.85.216.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Aug 2010 00:58:03 +0000 Received: by qwf7 with SMTP id 7so7908747qwf.11 for ; Fri, 06 Aug 2010 17:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=wdsR+mETO220NDXpKK0Pu5tkKX3FmjSmQRzbJoe76T0=; b=TKLX0nCDq9ksH7tOfas7j2eDJHjAHP8W35i42p/aDFWwHNso1eOMYj7jPCEYe7iiE6 HwwwX0tXiRKrRLERlzlQvlx2IowQSrvVqEGjt1QA4wjF/ba9sNdm8cN5O2Ms53Tt8t8v S6ddjiQ8+j+HUr7cgaS9+vLN6v3TX+s9Q6akI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=c2G8NRhNJRvcaB/7FDUhrohPG2xVE1reONcI9phjO93KKz67J98MVdC1DcvnrAmK/A kEFRuAUesPbg6T9ccNorZXmBn301uvrHWlGymePpNxeKAfwFvTmOX4SuytX1HHpkovox 0OKzgQUT6f6Cowb53hcWyk7mzvnV+Ca/26Les= MIME-Version: 1.0 Received: by 10.229.1.208 with SMTP id 16mr5140375qcg.264.1281142662367; Fri, 06 Aug 2010 17:57:42 -0700 (PDT) Received: by 10.229.222.145 with HTTP; Fri, 6 Aug 2010 17:57:42 -0700 (PDT) In-Reply-To: <3535538C-2389-4EC7-A5E3-862BC0F17EC1@apache.org> References: <50582255-EA47-4DDA-A182-13F54F9B1BF6@apache.org> <327C4C74-0F10-4F43-B18F-79BAD91717C1@gmail.com> <3535538C-2389-4EC7-A5E3-862BC0F17EC1@apache.org> Date: Sat, 7 Aug 2010 08:57:42 +0800 Message-ID: Subject: Re: Crash when using builtin reduce _stats From: Yue Chuan Lim To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0014853932ba4c0b4b048d314505 X-Virus-Checked: Checked by ClamAV on apache.org --0014853932ba4c0b4b048d314505 Content-Type: text/plain; charset=ISO-8859-1 Also, I can verify that a temp view with any number of trailing linefeeds (and whitespace) on the reduce function works fine (looks like for a temp-view the text gets tossed into a javascript eval?), but for an actual view, the reduce function needs to be just "_stats". Should I still open a JIRA ticket? Thanks for your help in tracking this down, much appreciated! Yue Chuan On Sat, Aug 7, 2010 at 8:50 AM, J Chris Anderson wrote: > > On Aug 6, 2010, at 5:41 PM, Yue Chuan Lim wrote: > > > It appears that a trailing linefeed is the cause of my problems. > > > > On the working function, the reduce function is simply "_stats" on the > > failing function it is "_stats\u000a" > > > > ahhh, ye old linefeed bug. > > nuff said. if someone can provide a test case for this, the actual bug fix > should be trivial. > > I think the behavior should be a prefix test, so that even "_statsorama" or > "_stats\nare\awesome" should work just as "_stats" does. > > Chris > > > --- message below retained for prosperity, in the event I am wrong > > > > After playing around with the function (as above, ensuring that there are > no > > non-numeric values, as well as removing and eventually readding the > 0 > > test), it suddenly starts working. > > > > // revision 18 - works, renamed to stats_pass > > { > > "_id": "_design/stats", > > "_rev": "18-776464ea3e4e548f44c55aa8b889f8a1", > > "langauge": "javascript", > > "views": { > > "active_power": { > > "map": "function(doc) {\u000a if(doc.data[12] > 0) {\u000a > > key = doc._id.split(\"|\")[0];\u000a emit(key, doc.data[12]);\u000a > > }\u000a}\u000a\u000a", > > "reduce": "_stats" > > } > > }, > > "language": "javascript" > > } > > > > // revision 14 (15, 16, 17 are variants of this), when I removed the > reduce > > function to run the tests as per above > > { > > "_id": "_design/stats", > > "_rev": "14-416ed97296c70d0c53215c210ebcf464", > > "langauge": "javascript", > > "views": { > > "active_power": { > > "map": "function(doc) {\u000a if(doc.data[12] > 0) {\u000a > > key = doc._id.split(\"|\")[0];\u000a emit(key, doc.data[12]);\u000a > > }\u000a}\u000a\u000a" > > } > > }, > > "language": "javascript" > > } > > > > // revision 13, the failing revision > > { > > "_id": "_design/stats", > > "_rev": "13-9549c38bb346d590749adc81f3f6c7e2", > > "langauge": "javascript", > > "views": { > > "active_power": { > > "map": "function(doc) {\u000a if(doc.data[12] > 0) {\u000a > > key = doc._id.split(\"|\")[0];\u000a emit(key, doc.data[12]);\u000a > > }\u000a}\u000a\u000a", > > "reduce": "_stats\u000a" > > } > > }, > > "language": "javascript" > > } > > > > These appear to me as essentially identical views (13 and 18). but 13 > fails > > and 18 passes. Copy/pasting them to a new view (i.e. stats_pass (rev 18) > and > > stats_fail (rev 13)) on a couch.io instance, and they continue to pass > and > > fail respectively. > > > > http://shasderias.couchone_remove_me_ > > .com/gsc_lt2/_design/stats_pass/_view/active_power > > http://shasderias.couchone_remove_me_ > > .com/gsc_lt2/_design/stats_fails/_view/active_power > > > > On Sat, Aug 7, 2010 at 8:24 AM, J Chris Anderson > wrote: > > > >> > >> On Aug 6, 2010, at 5:21 PM, Yue Chuan Lim wrote: > >> > >>> I highly doubt it, modifying the function to: > >>> > >>> function(doc) { > >>> if(doc.data[12] > 0) { > >>> key = doc._id.split("|")[0]; > >>> emit(doc.data[12], doc.data[12]); > >>> } > >>> } > >>> > >>> and sorting by key, it appears all the numbers are indeed numbers. > >>> > >>> function(doc) { > >>> if(doc.data[12] > 0) { > >>> key = doc._id.split("|")[0]; > >>> if(doc.data[12] != parseInt(doc.data[12])) { > >>> emit(doc.data[12], doc.data[12]); > >>> } > >>> } > >>> } > >>> > >>> Returns a empty set. > >>> > >>> On a hunch, I removed the doc.data[12] > 0 line, and the query seems to > >> run > >>> fine > >>> > >>> (with group=true) > >>> > >>> {"rows":[ > >>> > >> > {"key":"gsc_test_01","value":{"sum":335168,"count":1000,"min":0,"max":389,"sumsqr":128263850}}, > >>> > >> > {"key":"gsc_test_02","value":{"sum":381805,"count":1000,"min":0,"max":765,"sumsqr":176920147}}, > >>> > >> > {"key":"gsc_test_03","value":{"sum":411391,"count":1000,"min":187,"max":761,"sumsqr":178307983}} > >>> ]} > >>> > >>> So it appears that _stats doesn't like value sets without 0s :P (or > maybe > >>> reduce + group=true has something against unequal count values) > >>> > >>> Thanks for looking into this :) > >> > >> Since there isn't an easy answer in sight, and I'm up to my neck in > other > >> patches right now, maybe the best thing to do is start a Jira ticket to > >> record your observations while they are still fresh. > >> > >> http://issues.apache.org/jira/browse/COUCHDB > >> > >> Thanks, > >> Chris > >> > >>> Yue Chuan > >>> > >>> > >>> On Sat, Aug 7, 2010 at 8:13 AM, J Chris Anderson > >> wrote: > >>> > >>>> > >>>> On Aug 6, 2010, at 5:09 PM, Yue Chuan Lim wrote: > >>>> > >>>>> Further tested on the couch.io windows installer as well as a > >>>>> couch.ioinstance with the same results, works on a temp view, crashes > >>>>> on a actual > >>>>> view. > >>>>> > >>>>> > >>>> > >> > shasderias.couchone_remove_me_.com/_utils/database.html?gsc_lt2/_design/stats/_view/active_power > >>>>> > >>>>> is the couchone instance. > >>>> > >>>> Is there any chance you have a few docs where the value is not a > number? > >> If > >>>> you remove the reduce function completely and query the map is every > >> single > >>>> row's value a number? > >>>> > >>>> Thanks for helping us get to the bottom of this. > >>>> > >>>> Chris > >>>> > >>>>> > >>>>> On Fri, Aug 6, 2010 at 9:01 PM, Yue Chuan Lim > >>>> wrote: > >>>>> > >>>>>> And curiously enough, running it as a temp view works just fine. > >>>>>> > >>>>>> [info] [<0.1859.0>] 127.0.0.1 - - 'POST' > >>>>>> /gsc_lt2/_temp_view?limit=11&descending=true&group=true 200 > >>>>>> > >>>>>> > >>>>>> On Fri, Aug 6, 2010 at 8:38 PM, Yue Chuan Lim >>>>> wrote: > >>>>>> > >>>>>>> Fairly standard map/reduce function, map looks something like > >>>>>>> > >>>>>>> function(doc) { > >>>>>>> if(doc.data[12] > 0) { > >>>>>>> key = doc._id.split("|")[0]; > >>>>>>> emit(key, doc.data[12]); > >>>>>>> } > >>>>>>> } > >>>>>>> > >>>>>>> Data returned by map is along the lines of: ("test1", 123), > ("test1", > >>>>>>> 245). > >>>>>>> > >>>>>>> Reduce is just: _stats > >>>>>>> > >>>>>>> Crash log: http://pastebin.com/aX7jeeLm > >>>>>>> Platform: Windows 7 (32-bit) > >>>>>>> > >>>>>>> Using the installer by Mark Hammond. Incidentally, is the installer > >> on > >>>>>>> couch.io the preferred one for windows deployment? > >>>>>>> > >>>>>>> Thanks > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>> > >>>> > >>>> > >> > >> > > --0014853932ba4c0b4b048d314505--