activemq-artemis git commit: ARTEMIS-1111 Fixing deadlock

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

activemq-artemis git commit: ARTEMIS-1111 Fixing deadlock

clebertsuconic-2
Repository: activemq-artemis
Updated Branches:
  refs/heads/master ee261e736 -> bfc07a7e0


ARTEMIS-1111 Fixing deadlock

There is a deadlock on flow controlling
the lock is using the wrong method and that is causing some issues under perf load.


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

Branch: refs/heads/master
Commit: bfc07a7e01827d663db7ca0901178d20bafb92d5
Parents: ee261e7
Author: Clebert Suconic <[hidden email]>
Authored: Mon Apr 17 14:14:12 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Mon Apr 17 21:31:17 2017 -0400

----------------------------------------------------------------------
 .../amqp/broker/AMQPSessionCallback.java         |  9 ++++++---
 .../amqp/proton/AMQPConnectionContext.java       |  9 ++++-----
 .../amqp/proton/ProtonServerSenderContext.java   |  2 +-
 .../amqp/proton/handler/ProtonHandler.java       | 19 +++++++++++++++++--
 4 files changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bfc07a7e/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
index 2682e0f..9e54d41 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
@@ -472,22 +472,25 @@ public class AMQPSessionCallback implements SessionCallback {
             connection.lock();
             try {
                receiver.flow(credits);
-               connection.flush();
             } finally {
                connection.unlock();
             }
+            connection.flush();
             return;
          }
          final PagingStore store = manager.getServer().getPagingManager().getPageStore(new SimpleString(address));
          store.checkMemory(new Runnable() {
             @Override
             public void run() {
-               synchronized (connection.getLock()) {
+               connection.lock();
+               try {
                   if (receiver.getRemoteCredit() <= threshold) {
                      receiver.flow(credits);
-                     connection.flush();
                   }
+               } finally {
+                  connection.unlock();
                }
+               connection.flush();
             }
          });
       } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bfc07a7e/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
index 2c968c7..0173631 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
@@ -24,7 +24,6 @@ import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantLock;
 
 import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
@@ -129,16 +128,16 @@ public class AMQPConnectionContext extends ProtonInitializable implements EventH
       return false;
    }
 
-   public ReentrantLock getLock() {
-      return handler.getLock();
+   public boolean tryLock(long time, TimeUnit timeUnit) {
+      return handler.tryLock(time, timeUnit);
    }
 
    public void lock() {
-      handler.getLock().lock();
+      handler.lock();
    }
 
    public void unlock() {
-      handler.getLock().unlock();
+      handler.unlock();
    }
 
    public int capacity() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bfc07a7e/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
index 4b66b52..ccc93b7 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
@@ -630,7 +630,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
 
          int size = nettyBuffer.writerIndex();
 
-         while (!connection.getLock().tryLock(1, TimeUnit.SECONDS)) {
+         while (!connection.tryLock(1, TimeUnit.SECONDS)) {
             if (closed || sender.getLocalState() == EndpointState.CLOSED) {
                // If we're waiting on the connection lock, the link might be in the process of closing.  If this happens
                // we return.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bfc07a7e/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
index fc6cbf6..f1be934 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
@@ -114,8 +114,23 @@ public class ProtonHandler extends ProtonInitializable {
       }
    }
 
-   public ReentrantLock getLock() {
-      return lock;
+   public void lock() {
+      lock.lock();
+   }
+
+   public void unlock() {
+      lock.unlock();
+   }
+
+   public boolean tryLock(long time, TimeUnit timeUnit) {
+      try {
+         return lock.tryLock(time, timeUnit);
+      } catch (InterruptedException e) {
+
+         Thread.currentThread().interrupt();
+         return false;
+      }
+
    }
 
    public Transport getTransport() {

Loading...