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 BA89E173AE for ; Thu, 30 Oct 2014 14:41:34 +0000 (UTC) Received: (qmail 43417 invoked by uid 500); 30 Oct 2014 14:41:34 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 43346 invoked by uid 500); 30 Oct 2014 14:41:34 -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 43334 invoked by uid 99); 30 Oct 2014 14:41:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Oct 2014 14:41:34 +0000 Date: Thu, 30 Oct 2014 14:41:34 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: dev@couchdb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COUCHDB-2365) Failing multipart requests leave dangling couch_stream processes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-2365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14190147#comment-14190147 ] ASF subversion and git services commented on COUCHDB-2365: ---------------------------------------------------------- Commit f02a1013dc61f011ccb58f1fddb689a93795af98 in couchdb-couch's branch refs/heads/two-factor-auth from [~mikewallace] [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=f02a101 ] Make couch_stream monitor the stream opener This commit fixes a process leak which would happen when a process opened a couch_stream and exited with reason normal before closing the stream. This patch makes the couch_stream gen_server monitor the process which opens the stream. When that monitor sends an exit signal the couch_stream gen_server is stopped and the process dies. Closes COUCHDB-2365 > Failing multipart requests leave dangling couch_stream processes > ---------------------------------------------------------------- > > Key: COUCHDB-2365 > URL: https://issues.apache.org/jira/browse/COUCHDB-2365 > Project: CouchDB > Issue Type: Bug > Security Level: public(Regular issues) > Components: Database Core > Affects Versions: 1.5.1, 1.6.0 > Reporter: Mike Wallace > Priority: Minor > Fix For: 2.0.0 > > > Multipart requests spawn a couch_stream gen_server when couch_stream:open/2 is called in couch_db:with_stream/3 [1]. Currently this gen_server will only be stopped when couch_db:with_stream/3 calls couch_stream:close/1 which happens after the callback Fun is executed [2]. If anything goes wrong before closing the stream then the couch_stream gen_server will exit as long as the process that opened the stream exits with a reason other than normal (since the processes are linked). However, if the process which opened the stream exits with reason normal before closing the stream then the process will live indefinitely. > Ordinarily this is not particularly bothersome however if the volume of failing multipart requests is high the resources consumed by these dangling processes can be significant (consuming all available memory in the worst case). > This can be reproduced by making failing multipart requests and observing the number of processes with initial call couch_stream:init/1 e.g.: https://gist.github.com/mikewallace1979/baad43ecfc01506ba8c5 > [1] https://github.com/apache/couchdb-couch/blob/master/src/couch_db.erl#L1108-L1121 > [2] https://github.com/apache/couchdb-couch/blob/master/src/couch_db.erl#L1123-L1133 -- This message was sent by Atlassian JIRA (v6.3.4#6332)