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 1B003D8C6 for ; Fri, 3 Aug 2012 17:37:27 +0000 (UTC) Received: (qmail 91416 invoked by uid 500); 3 Aug 2012 17:37:25 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 91367 invoked by uid 500); 3 Aug 2012 17:37:25 -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 91359 invoked by uid 99); 3 Aug 2012 17:37:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2012 17:37:25 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.220.180 as permitted sender) Received: from [209.85.220.180] (HELO mail-vc0-f180.google.com) (209.85.220.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2012 17:37:20 +0000 Received: by vcbfw7 with SMTP id fw7so898956vcb.11 for ; Fri, 03 Aug 2012 10:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=fshYZPFRulvRUnpK4ZtRa343ThlqNp3JSfzuPFA5EeY=; b=Y8VeRDu+g9FsKCfrFTJPyPCr4a0IquRp441NxxPw8ojs+U6j4nUq0EhTlTeFgfZ+xP oJq4zSzE1hQPnHWB7XFIElUAGr+z1DXq7JFiyny2T9MC5uQ1q+aNIKm3kqIfUjFppaEk I3dLHpI8XmFUo02EPu52uuZvNZyqfwWyrEqJ8FpTPotf/UM5J78LS76MNq8GnkjjMjBo pxcdkH3nI1FG+u2AR7/RejjVPcoCowntRHWJmK5JbNKIe5hT4RrX6G/1/A3i2Dkqs0e9 PVJ6ShazzEPJlZGKfEjX3HWWak6gNiBRy37rIJidjIqs9K7fdeoIIBJ/nCro+6hiVWnS XyMg== Received: by 10.52.36.180 with SMTP id r20mr1730800vdj.15.1344015419912; Fri, 03 Aug 2012 10:36:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.221.10.141 with HTTP; Fri, 3 Aug 2012 10:36:18 -0700 (PDT) In-Reply-To: <12119867-1D77-4943-B87C-B8369C7005C8@couchbase.com> References: <12119867-1D77-4943-B87C-B8369C7005C8@couchbase.com> From: Paul Davis Date: Fri, 3 Aug 2012 12:36:18 -0500 Message-ID: Subject: Re: function_clause error in HTTP request To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Aug 3, 2012 at 12:24 PM, Jens Alfke wrote: > > On Aug 3, 2012, at 12:33 AM, Pieter van der Eems wrote: > >> We have an IOS client using TouchDB which syncs with CouchDB (1.2) on >> our server. >> The IOS client is a black box for me so I can't do any debugging there. > > The HTTP headers in the logs show that it's TouchDB 0.8; the latest relea= se is 0.93. If this is an app in the wild it's understandable that it's not= running the latest release, but there have been several multipart upload b= ugs fixed since then (where "then" =3D June 20) that _might_ be causing thi= s. > > IIRC, most of those bugs involved HTTP auth; is that involved here? The h= eaders in the pastie don't include "Authorization:" but that might have bee= n stripped from the log for security purposes. > > When I was debugging these, it was the CouchDB side that was the black bo= x :) so I'm curious to know what the CouchDB experts make of the logs you c= aptured, i.e. what they imply might have been wrong with the formatting of = the multipart data. > > [Fri, 03 Aug 2012 07:12:52 GMT] [error] [<0.2639.144>] function_= clause error in HTTP request > [Fri, 03 Aug 2012 07:12:52 GMT] [info] [<0.2639.144>] Stacktrace= : [{couch_db,write_streamed_attachment, > [<0.4031.144>, > #Fun,-1576], > [{file, > "/opt/build-couchdb/depend= encies/couchdb/src/couchdb/couch_db.erl"}, > {line,1031}]}, > > In the CouchDB sources I have on hand (which are not up-to-date with 1.2)= write_streamed_attachment looks like >> write_streamed_attachment(_Stream, _F, 0) -> >> ok; >> write_streamed_attachment(Stream, F, LenLeft) when LenLeft > 0 -> >> Bin =3D read_next_chunk(F, LenLeft), >> ok =3D couch_stream:write(Stream, Bin), >> write_streamed_attachment(Stream, F, LenLeft - size(Bin)). > > I'm very weak at Erlang, but I think what happened is that the call to th= is function didn't match either of those patterns, which would imply that L= enLeft < 0. Which in turn would imply that in the previous call to read_nex= t_chunk returned a number larger than LenLeft; I'm not sure whether or not = this is possible... > > =97Jens I've seen errors like this before. IIRC, the underlying issue is that there's a bug in the attachment handling related to gzipped vs identity content lengths. Specifically I think it was when CouchDB receives an attachment that's gzipped it doesn't bother doing an "gunzip > /dev/null" type operation to get the identity length and then when it sends the attachment to something that doesn't understand gzip compression there's a mismatch in what lengths are expected. Or something along those lines.