[ 
https://issues.apache.org/jira/browse/AMQ-5396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14175667#comment-14175667
 ] 

AR commented on AMQ-5396:
-------------------------

Test case to reproduce this (with Mqtt Paho client lib):

* In the broker source, in 
activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
 add sleep between the 2 lines in function addConnection() as shown below:
{noformat}
                            TransportConnection transportConnection = 
(TransportConnection) connection;
                             Thread.sleep(30000);
                             transportConnection.stopAsync();
{noformat}

* Run the broker
* Run the following test case:
{noformat}
    @Test
    public void testLinkStealingDeadlock2() throws MqttException, 
InterruptedException
    {
        MqttClient client1 = new MqttClient("tcp://localhost:1883", "client1");

        client1.connect();

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    System.out.println("Connecting client 2....");
                    MqttClient client2 = new MqttClient("tcp://localhost:1883", 
"client1"); // should be same client id
                    client2.connect();
                    System.out.println("Done connecting client2");
                } catch (MqttException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });
        thread.start(); 
        Thread.sleep(2000);
        System.out.println("Disconnecting client1...");
        client1.disconnect();

        System.out.println("Connecting client3...");
        MqttClient client3 = new MqttClient("tcp://localhost:1883", "client3");
        client3.connect();

        System.out.println("Client3 connected");

        client3.disconnect();


        Thread.sleep(120*1000);
        Assert.assertTrue(true);
    }
{noformat}

* Run jstack on the JVM


> Linkstealing causes deadlock when old client disconnects before link stealing 
> adds the connection
> -------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-5396
>                 URL: https://issues.apache.org/jira/browse/AMQ-5396
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.11.0
>            Reporter: Sai
>         Attachments: jstack.txt, linkstealing-deadlock.patch
>
>
> During link stealing in progress if the old client(or connection) issues a 
> disconnect can cause a deadlock due the order in which the locks are obtained 
> on RegionBroker.addConnection and TransportConnection.processRemoveConneciton.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to