From afdb78dd5c8aae5d39e53f4b6390708f3602761f Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Wed, 23 Mar 2016 15:33:49 +0000 Subject: [PATCH] ARTEMIS-456 Synchronize sendReplicatePacket method There is a potential deadlock scenario if 2 threads try sendReplicatePacket. Thread 1 registers Netty callback which will invoke readyForWrites() method, which locks the callback list and waits on the replicationLock. Thread 2 enters sendReplicatePacket and gets the replicationLock and is blocked on the callback list lock. This fix ensures the sendReplicatePacket blocks on the ReplicationManager meaning no interleaving of the Netty callback thread and the wait on lock can happen. --- .../activemq/artemis/core/replication/ReplicationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java index a393816714..4aabbeae07 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java @@ -330,7 +330,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene return sendReplicatePacket(packet, true); } - private OperationContext sendReplicatePacket(final Packet packet, boolean lineUp) { + private synchronized OperationContext sendReplicatePacket(final Packet packet, boolean lineUp) { if (!enabled) return null; boolean runItNow = false;