Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DCA99200CD3 for ; Fri, 28 Jul 2017 16:33:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DB1FF16CD3F; Fri, 28 Jul 2017 14:33:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2DB2B16CD31 for ; Fri, 28 Jul 2017 16:33:49 +0200 (CEST) Received: (qmail 90666 invoked by uid 500); 28 Jul 2017 14:33:48 -0000 Mailing-List: contact commits-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 commits@activemq.apache.org Received: (qmail 90653 invoked by uid 99); 28 Jul 2017 14:33:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jul 2017 14:33:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 632FBE973B; Fri, 28 Jul 2017 14:33:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Fri, 28 Jul 2017 14:33:48 -0000 Message-Id: <71fcfcd22ce84a6e83cbb22f9eca8b90@git.apache.org> In-Reply-To: <84230138ea6c4783b863805f036487d9@git.apache.org> References: <84230138ea6c4783b863805f036487d9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] activemq-artemis git commit: ARTEMIS-1305 Server frozen during shutdown on Resource Adapter archived-at: Fri, 28 Jul 2017 14:33:50 -0000 ARTEMIS-1305 Server frozen during shutdown on Resource Adapter this is a better fix than the previous one Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/54d220ed Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/54d220ed Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/54d220ed Branch: refs/heads/master Commit: 54d220edf309647d3f9e17854ebbda7a984dfedf Parents: 40534b2 Author: Clebert Suconic Authored: Fri Jul 28 09:38:19 2017 -0400 Committer: Clebert Suconic Committed: Fri Jul 28 10:33:40 2017 -0400 ---------------------------------------------------------------------- .../artemis/ra/ActiveMQRAManagedConnection.java | 41 ++++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d220ed/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java ---------------------------------------------------------------------- diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java index e53c3fd..eee41cc 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java @@ -221,6 +221,14 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc ActiveMQRALogger.LOGGER.trace("destroyHandles()"); } + try { + if (connection != null) { + connection.stop(); + } + } catch (Throwable t) { + logger.trace("Ignored error stopping connection", t); + } + for (ActiveMQRASession session : handles) { session.destroy(); } @@ -255,7 +263,10 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc } try { - connectionFactory.close(); + // we must close the ActiveMQConnectionFactory because it contains a ServerLocator + if (connectionFactory != null) { + ra.closeConnectionFactory(mcf.getProperties()); + } } catch (Exception e) { logger.debug(e.getMessage(), e); } @@ -263,10 +274,32 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc destroyHandles(); try { - // we must close the ActiveMQConnectionFactory because it contains a ServerLocator - if (connectionFactory != null) { - ra.closeConnectionFactory(mcf.getProperties()); + // The following calls should not be necessary, as the connection should close the + // ClientSessionFactory, which will close the sessions. + try { + /** + * (xa|nonXA)Session.close() may NOT be called BEFORE connection.close() + *

+ * If the ClientSessionFactory is trying to fail-over or reconnect with -1 attempts, and + * one calls session.close() it may effectively dead-lock. + *

+ * connection close will close the ClientSessionFactory which will close all sessions. + */ + if (connection != null) { + connection.close(); + } + + if (nonXAsession != null) { + nonXAsession.close(); + } + + if (xaSession != null) { + xaSession.close(); + } + } catch (JMSException e) { + ActiveMQRALogger.LOGGER.debug("Error closing session " + this, e); } + } catch (Throwable e) { throw new ResourceException("Could not properly close the session and connection", e); }