activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1506 Synchronization issue during failover in ClientSessionImpl
Date Thu, 09 Nov 2017 16:57:37 GMT
ARTEMIS-1506 Synchronization issue during failover in ClientSessionImpl

The temporary deadlock is avoided by removing 'synchronized' from
ClientSessionImpl::getCredits method. As the method uses only
a producerCreditManger, only this object is guarded against
the parallel access.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/5cc8faed
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/5cc8faed
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/5cc8faed

Branch: refs/heads/master
Commit: 5cc8faedd8fd2e80975c2aa12f8f30c1724b9626
Parents: 93f4e41
Author: Erich Duda <dudaerich@gmail.com>
Authored: Fri Nov 3 16:19:54 2017 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Nov 9 11:52:44 2017 -0500

----------------------------------------------------------------------
 .../core/client/impl/ClientSessionImpl.java     | 31 +++++++++++++-------
 1 file changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5cc8faed/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
index 41330a6..61784ad 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
@@ -1156,7 +1156,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
       try {
          closeChildren();
 
-         synchronized (this) {
+         synchronized (producerCreditManager) {
             producerCreditManager.close();
          }
          inClose = true;
@@ -1177,7 +1177,9 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
          return;
       }
 
-      producerCreditManager.close();
+      synchronized (producerCreditManager) {
+         producerCreditManager.close();
+      }
 
       cleanUpChildren();
 
@@ -1282,7 +1284,9 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
          }
 
          if (resetCreditManager) {
-            producerCreditManager.reset();
+            synchronized (producerCreditManager) {
+               producerCreditManager.reset();
+            }
 
             // Also need to send more credits for consumers, otherwise the system could hand
with the server
             // not having any credits to send
@@ -1343,25 +1347,32 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
    }
 
    @Override
-   public synchronized ClientProducerCredits getCredits(final SimpleString address, final
boolean anon) {
-      ClientProducerCredits credits = producerCreditManager.getCredits(address, anon, sessionContext);
-
-      return credits;
+   public ClientProducerCredits getCredits(final SimpleString address, final boolean anon)
{
+      synchronized (producerCreditManager) {
+         ClientProducerCredits credits = producerCreditManager.getCredits(address, anon,
sessionContext);
+         return credits;
+      }
    }
 
    @Override
    public void returnCredits(final SimpleString address) {
-      producerCreditManager.returnCredits(address);
+      synchronized (producerCreditManager) {
+         producerCreditManager.returnCredits(address);
+      }
    }
 
    @Override
    public void handleReceiveProducerCredits(final SimpleString address, final int credits)
{
-      producerCreditManager.receiveCredits(address, credits);
+      synchronized (producerCreditManager) {
+         producerCreditManager.receiveCredits(address, credits);
+      }
    }
 
    @Override
    public void handleReceiveProducerFailCredits(final SimpleString address, int credits)
{
-      producerCreditManager.receiveFailCredits(address, credits);
+      synchronized (producerCreditManager) {
+         producerCreditManager.receiveFailCredits(address, credits);
+      }
    }
 
    @Override


Mime
View raw message