Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 36823 invoked from network); 18 May 2009 00:44:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 May 2009 00:44:51 -0000 Received: (qmail 35898 invoked by uid 500); 18 May 2009 00:44:50 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 35802 invoked by uid 500); 18 May 2009 00:44:50 -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 35792 invoked by uid 99); 18 May 2009 00:44:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 May 2009 00:44:50 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of adam.kocoloski@gmail.com designates 74.125.92.24 as permitted sender) Received: from [74.125.92.24] (HELO qw-out-2122.google.com) (74.125.92.24) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 May 2009 00:44:39 +0000 Received: by qw-out-2122.google.com with SMTP id 5so1944616qwd.29 for ; Sun, 17 May 2009 17:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=3dJmi1y2Ej6o7caDwxEEmKYay5jWABxTTJ195VEXVaU=; b=LglFEEIUFb36vFNOtk9ap7rb6IkTpoDSvcC5OlTRSNb+5Tsww3au2QiqEiA9LR/E1d fNxtQ3we+cjiEpsbEYs81e7OtH7tqz4Gb+u344JreFd2h0oxPMozgxoL281ufhlbf5Qw 6iKUTsLb82ZP0EF14lFgRULGm3XgbDxUI4n08= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=WhiZhKhKjCd3dI0XnQ2y+58nXcOtOUPf96SKh+UwspeLVW63uVuDLvUQ44rTKic5V2 2eweCkSCQHmRGfiFDtOL1faMFjbbwk4NiNW0J+9ZFkfWMWUQHISsNKgDKx8sCi6ir6fP fyZSXQAU06DzC/0YbrfBTycOPcKekLhugCe0I= Received: by 10.224.11.1 with SMTP id r1mr5882810qar.222.1242607458132; Sun, 17 May 2009 17:44:18 -0700 (PDT) Received: from ?10.0.1.4? ([71.232.49.44]) by mx.google.com with ESMTPS id 5sm167491qwg.29.2009.05.17.17.44.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 17 May 2009 17:44:17 -0700 (PDT) Sender: Adam Kocoloski Message-Id: <75537FBA-C3E7-4A06-9B08-0DA70BCB00C3@apache.org> From: Adam Kocoloski To: dev@couchdb.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: svn commit: r775634 - /couchdb/branches/0.9.x/src/couchdb/couch_db.erl Date: Sun, 17 May 2009 20:44:15 -0400 References: <20090517122922.E565923888DB@eris.apache.org> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org Sure, I agree. Consider this commit a stopgap until we're able to pin down the source of the problem. Antony, any chance you can make that 100% reproducible case publicly available? Adam On May 17, 2009, at 5:10 PM, Damien Katz wrote: > +%% on rare occasions ibrowse seems to process a chunked response > incorrectly > +%% and include an extra "\r" in the last chunk. This code ensures > that we > +%% truncate the downloaed attachment at the length specified in the > metadata. > > That really sucks. We need to either fix ibrowse or drop it > altogether. > > -Damien > > On May 17, 2009, at 8:29 AM, kocolosk@apache.org wrote: > >> Author: kocolosk >> Date: Sun May 17 12:29:22 2009 >> New Revision: 775634 >> >> URL: http://svn.apache.org/viewvc?rev=775634&view=rev >> Log: >> work around ibrowse giving response chunks too many bytes. Thanks >> Antony. >> >> Modified: >> couchdb/branches/0.9.x/src/couchdb/couch_db.erl >> >> Modified: couchdb/branches/0.9.x/src/couchdb/couch_db.erl >> URL: http://svn.apache.org/viewvc/couchdb/branches/0.9.x/src/couchdb/couch_db.erl?rev=775634&r1=775633&r2=775634&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- couchdb/branches/0.9.x/src/couchdb/couch_db.erl (original) >> +++ couchdb/branches/0.9.x/src/couchdb/couch_db.erl Sun May 17 >> 12:29:22 2009 >> @@ -649,12 +649,24 @@ >> {ok, SpAcc}; >> write_streamed_attachment(Stream, F, LenLeft, nil) -> >> Bin = F(), >> - {ok, StreamPointer} = couch_stream:write(Stream, Bin), >> - write_streamed_attachment(Stream, F, LenLeft - size(Bin), >> StreamPointer); >> + TruncatedBin = check_bin_length(LenLeft, Bin), >> + {ok, SpAcc} = couch_stream:write(Stream, TruncatedBin), >> + write_streamed_attachment(Stream, F, LenLeft - >> size(TruncatedBin), SpAcc); >> write_streamed_attachment(Stream, F, LenLeft, SpAcc) -> >> Bin = F(), >> - {ok, _} = couch_stream:write(Stream, Bin), >> - write_streamed_attachment(Stream, F, LenLeft - size(Bin), >> SpAcc). >> + TruncatedBin = check_bin_length(LenLeft, Bin), >> + {ok, _} = couch_stream:write(Stream, TruncatedBin), >> + write_streamed_attachment(Stream, F, LenLeft - >> size(TruncatedBin), SpAcc). >> + >> +%% on rare occasions ibrowse seems to process a chunked response >> incorrectly >> +%% and include an extra "\r" in the last chunk. This code ensures >> that we >> +%% truncate the downloaed attachment at the length specified in >> the metadata. >> +check_bin_length(LenLeft, Bin) when size(Bin) > LenLeft -> >> + <> = Bin, >> + ?LOG_ERROR("write_streamed_attachment has written too much >> expected: ~p" ++ >> + " got: ~p tail: ~p", [LenLeft, size(Bin), Crap]), >> + ValidData; >> +check_bin_length(_, Bin) -> Bin. >> >> enum_docs_since_reduce_to_count(Reds) -> >> couch_btree:final_reduce( >> >> >