Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-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 9F5BE116B9 for ; Mon, 7 Jul 2014 18:30:35 +0000 (UTC) Received: (qmail 44906 invoked by uid 500); 7 Jul 2014 18:30:35 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 44860 invoked by uid 500); 7 Jul 2014 18:30:35 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 44844 invoked by uid 99); 7 Jul 2014 18:30:35 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jul 2014 18:30:35 +0000 Date: Mon, 7 Jul 2014 18:30:35 +0000 (UTC) From: "Timothy Bish (JIRA)" To: dev@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (AMQ-5258) Connection reference leak in PooledConnectionFactory leading to expired connections stuck in the pool 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/AMQ-5258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Timothy Bish resolved AMQ-5258. ------------------------------- Resolution: Fixed Fix Version/s: 5.11.0 Assignee: Timothy Bish Fixed, connection is created and closed to allow it to reside in the pool as unused and error out or time out as expect. > Connection reference leak in PooledConnectionFactory leading to expired connections stuck in the pool > ----------------------------------------------------------------------------------------------------- > > Key: AMQ-5258 > URL: https://issues.apache.org/jira/browse/AMQ-5258 > Project: ActiveMQ > Issue Type: Bug > Components: activemq-pool > Affects Versions: 5.9.1, 5.10.0 > Reporter: Sergiy Barlabanov > Assignee: Timothy Bish > Fix For: 5.11.0 > > > org.apache.activemq.jms.pool.PooledConnectionFactory creates a connection on startup without giving it back to the pool: > {code:java} > public void start() { > LOG.debug("Staring the PooledConnectionFactory: create on start = {}", isCreateConnectionOnStartup()); > stopped.set(false); > if (isCreateConnectionOnStartup()) { > try { > // warm the pool by creating a connection during startup > createConnection(); > } catch (JMSException e) { > LOG.warn("Create pooled connection during start failed. This exception will be ignored.", e); > } > } > } > {code} > So no close() method of PooledConnection is called and so no decrementReferenceCount is called on ConnectionPool. So referenceCount never becomes 0. > Later on if an exception occurs and hasExpired of ConnectionPool is set to true, the connection will not be closed since expiredCheck() method of ConnectionPool always compares referenceCount with 0 and does close() only if it is 0. > So we have a dead ConnectionPool instance and all usages result in "XXX closed" errors. > The fix would be to add call to close() just after doing createConnection() in PooledConnectionFactory#start() to make referenceCount go to 0. Something like this: > {code:java} > public void start() { > LOG.debug("Staring the PooledConnectionFactory: create on start = {}", isCreateConnectionOnStartup()); > stopped.set(false); > if (isCreateConnectionOnStartup()) { > try { > // warm the pool by creating a connection during startup > createConnection().close(); // <--- makes sure referenceCount goes to 0 > } catch (JMSException e) { > LOG.warn("Create pooled connection during start failed. This exception will be ignored.", e); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)