You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Claudio Corsi (Created) (JIRA)" <ji...@apache.org> on 2011/11/03 17:13:32 UTC

[jira] [Created] (AMQ-3577) The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.

The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.
----------------------------------------------------------------------------------------------------------------

                 Key: AMQ-3577
                 URL: https://issues.apache.org/jira/browse/AMQ-3577
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker, JMS client
    Affects Versions: 5.5.1
         Environment: any environment.
            Reporter: Claudio Corsi
             Fix For: 5.6.0


The connection close method does not properly clean up the connection on the broker.

This is causing a memory leak on the broker because the connection is dangling.

I have not confirmed that trying to call the close method within a non-interrupted thread will properly cleanup the connection after it was already called within an interrupted thread.

I have a test case that reproduces this issue and a patch that corrects the problem.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (AMQ-3577) The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.

Posted by "Claudio Corsi (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQ-3577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13143273#comment-13143273 ] 

Claudio Corsi edited comment on AMQ-3577 at 11/3/11 4:17 PM:
-------------------------------------------------------------

One more comment, I was able to produce an OOM exception by creating a connection, interrupting the thread and calling the close method in a loop.  

You can see that the connection was never cleaned up properly and eventually the broker slows to a crawl because of the OOM.

With the patch, the broker keeps going without any issues.

The main difference is that the thread count is increasing without the fix and with it the thread count does not.

A simple workaround is that the user calls does the following:

{code}

   // This will clear the interrupted state to allow the connection to cleanup properly
   boolean interrupt = Thread.interrupted();

   connection.close();

   if (interrupted) 
     // This will reset the interrupt state for this thread.
     Thread.currentThread().interrupt();

{code}


                
      was (Author: ccorsi):
    One more comment, I was able to produce an OOM exception by creating a connection, interrupting the thread and calling the close method in a loop.  

You can see that the connection was never cleaned up properly and eventually the broker slows to a crawl because of the OOM.

With the patch, the broker keeps going without any issues.

The main difference is that the thread count is increasing without the fix and with it the thread count does not.

A simple workaround is that the user calls does the following:

{code}

   boolean interrupt = Thread.interrupted();


                  
> The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-3577
>                 URL: https://issues.apache.org/jira/browse/AMQ-3577
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, JMS client
>    Affects Versions: 5.5.1
>         Environment: any environment.
>            Reporter: Claudio Corsi
>             Fix For: 5.6.0
>
>
> The connection close method does not properly clean up the connection on the broker.
> This is causing a memory leak on the broker because the connection is dangling.
> I have not confirmed that trying to call the close method within a non-interrupted thread will properly cleanup the connection after it was already called within an interrupted thread.
> I have a test case that reproduces this issue and a patch that corrects the problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (AMQ-3577) The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.

Posted by "Claudio Corsi (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQ-3577?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claudio Corsi closed AMQ-3577.
------------------------------

    Resolution: Fixed

This issue was fixed in trunk by Tim on the 29th of Oct.

The commit is http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java?r1=1195044&r2=1195045&.

He applied the same scheme that I was using to resolve the issue.

Note that the InvalidClientIDException was a symptom of this.
                
> The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-3577
>                 URL: https://issues.apache.org/jira/browse/AMQ-3577
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, JMS client
>    Affects Versions: 5.5.1
>         Environment: any environment.
>            Reporter: Claudio Corsi
>             Fix For: 5.6.0
>
>
> The connection close method does not properly clean up the connection on the broker.
> This is causing a memory leak on the broker because the connection is dangling.
> I have not confirmed that trying to call the close method within a non-interrupted thread will properly cleanup the connection after it was already called within an interrupted thread.
> I have a test case that reproduces this issue and a patch that corrects the problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (AMQ-3577) The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.

Posted by "Claudio Corsi (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQ-3577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13143301#comment-13143301 ] 

Claudio Corsi commented on AMQ-3577:
------------------------------------

Agreed, but this is caused by the client not properly handling an interrupted thread.  The broker does not seem to get the request to close the connection which gives the broker the impression that the connection is still active on the client side when in fact it was closed.

You can see the problem by just doing the following:

  1 - create a connection
  2 - interrupt the thread
  3 - close the connection
  4 - repeat 1-3 over and over

open the jconsole and check the thread count on the broker.  it keeps increasing until you get an oom exception.

                
> The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-3577
>                 URL: https://issues.apache.org/jira/browse/AMQ-3577
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, JMS client
>    Affects Versions: 5.5.1
>         Environment: any environment.
>            Reporter: Claudio Corsi
>             Fix For: 5.6.0
>
>
> The connection close method does not properly clean up the connection on the broker.
> This is causing a memory leak on the broker because the connection is dangling.
> I have not confirmed that trying to call the close method within a non-interrupted thread will properly cleanup the connection after it was already called within an interrupted thread.
> I have a test case that reproduces this issue and a patch that corrects the problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (AMQ-3577) The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.

Posted by "Claudio Corsi (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQ-3577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13143273#comment-13143273 ] 

Claudio Corsi commented on AMQ-3577:
------------------------------------

One more comment, I was able to produce an OOM exception by creating a connection, interrupting the thread and calling the close method in a loop.  

You can see that the connection was never cleaned up properly and eventually the broker slows to a crawl because of the OOM.

With the patch, the broker keeps going without any issues.

The main difference is that the thread count is increasing without the fix and with it the thread count does not.

A simple workaround is that the user calls does the following:

{code}

   boolean interrupt = Thread.interrupted();


                
> The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-3577
>                 URL: https://issues.apache.org/jira/browse/AMQ-3577
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, JMS client
>    Affects Versions: 5.5.1
>         Environment: any environment.
>            Reporter: Claudio Corsi
>             Fix For: 5.6.0
>
>
> The connection close method does not properly clean up the connection on the broker.
> This is causing a memory leak on the broker because the connection is dangling.
> I have not confirmed that trying to call the close method within a non-interrupted thread will properly cleanup the connection after it was already called within an interrupted thread.
> I have a test case that reproduces this issue and a patch that corrects the problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (AMQ-3577) The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.

Posted by "Gary Tully (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQ-3577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13143292#comment-13143292 ] 

Gary Tully commented on AMQ-3577:
---------------------------------

note: internally the broker should not be calling interrupt unless it catches an interrupted exception. But is should be able to handle interrupted exceptions as the occur in normal processing and continue if necessary.
                
> The Connection is not cleanup properly whenever the close method is called within a thread that was interrupted.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-3577
>                 URL: https://issues.apache.org/jira/browse/AMQ-3577
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, JMS client
>    Affects Versions: 5.5.1
>         Environment: any environment.
>            Reporter: Claudio Corsi
>             Fix For: 5.6.0
>
>
> The connection close method does not properly clean up the connection on the broker.
> This is causing a memory leak on the broker because the connection is dangling.
> I have not confirmed that trying to call the close method within a non-interrupted thread will properly cleanup the connection after it was already called within an interrupted thread.
> I have a test case that reproduces this issue and a patch that corrects the problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira