From issues-return-67131-archive-asf-public=cust-asf.ponee.io@commons.apache.org Thu Mar 29 16:05:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8682F180645 for ; Thu, 29 Mar 2018 16:05:03 +0200 (CEST) Received: (qmail 89689 invoked by uid 500); 29 Mar 2018 14:05:02 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 89673 invoked by uid 99); 29 Mar 2018 14:05:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2018 14:05:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id ED7691A056A for ; Thu, 29 Mar 2018 14:05:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -102.311 X-Spam-Level: X-Spam-Status: No, score=-102.311 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id KAvgoi804M_x for ; Thu, 29 Mar 2018 14:05:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id D9F275F175 for ; Thu, 29 Mar 2018 14:05:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 740BCE027A for ; Thu, 29 Mar 2018 14:05:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2F6FD255EB for ; Thu, 29 Mar 2018 14:05:00 +0000 (UTC) Date: Thu, 29 Mar 2018 14:05:00 +0000 (UTC) From: "Gary Gregory (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DBCP-484?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D164190= 46#comment-16419046 ]=20 Gary Gregory commented on DBCP-484: ----------------------------------- [~zhfeng]: Thank you for your PR!=C2=A0 Do you think you could augment your PR with a unit test that fails unless t= he {{main}} portion of the patch is applied? Thank you, Gary > Connection leak during XATransaction in high load > ------------------------------------------------- > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug > Affects Versions: 2.2.0 > Reporter: Emanuel Freitas > Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when th= e system is under heavy load. We're using commons-dbcp (latest version) + e= clipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connecti= on. We are trying to figure out what's the root cause and we think that mig= ht be some issue in the commons dbcp (not sure) . More specifically, this p= arte of the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext !=3D null) { > if (transactionContext.isActive()) { > if (transactionContext !=3D transactionRegistry.getActiveTransact= ionContext()) { > throw new SQLException("Connection can not be used while enli= sted in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListe= ner, but in > // rare cases another lister could have registered which uses the con= nection before > // our listener is called. In that rare case, trigger the transactio= n complete call now > transactionComplete(); =20 > }{code} > =C2=A0 > If the=C2=A0transactionContext is different than null but the state is no= t "active" (ex:=C2=A0STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it execut= es the=C2=A0transactionComplete mothod that clears the reference to a share= d connection and after that the connection is never closed (returned to the= pool).=C2=A0 > =C2=A0 > If we move the transactionComplete(); to an else,(see below), the connect= ion leak does not happen. > {code:java} > if (transactionContext !=3D null) { > if (transactionContext.isActive()) { > if (transactionContext !=3D transactionRegistry.getActiveTransact= ionContext()) { > throw new SQLException("Connection can not be used while enli= sted in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > =C2=A0 > After this the=C2=A0dbcp unit tests still pass but I'm not sure about thi= s changes. Can you please check? > Thanks > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)