You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "jbertram (via GitHub)" <gi...@apache.org> on 2024/04/30 16:11:25 UTC

[PR] ARTEMIS-3622 MQTT can deadlock on client cxn/discxn [activemq-artemis]

jbertram opened a new pull request, #4909:
URL: https://github.com/apache/activemq-artemis/pull/4909

   This commit fixes the deadlock described on ARTEMIS-3622 by moving the synchronization "up" a level from the MQTTSession to the MQTTConnectionManager. It also eliminates the synchronization on the MQTTSessionState in the MQTTConnectionManager because it's no longer needed. This change should not only eliminate the deadlock, but improve performance relatively as well.
   
   There is no test associated with this commit as I wasn't able to reproduce the deadlock with any kind of straight-forward test. There was a test linked on the Jira, but it involved intrusive and fragile scaffolding and wasn't ultimately tenable. That said, I did test this fix with that test and it was successful. In any case, I think static analysis should be sufficient here as the changes are pretty straight-forward.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ARTEMIS-3622 MQTT can deadlock on client cxn/discxn [activemq-artemis]

Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #4909:
URL: https://github.com/apache/activemq-artemis/pull/4909#discussion_r1608344664


##########
artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java:
##########
@@ -176,33 +174,27 @@ ServerSessionImpl createServerSession(String username, String password, String v
       return (ServerSessionImpl) serverSession;
    }
 
-   void disconnect(boolean failure) {
+   synchronized void disconnect(boolean failure) {
       if (session == null || session.getStopped()) {
          return;
       }
 
-      synchronized (session.getState()) {

Review Comment:
   I've looked through it carefully and I don't see any potential problems. The relevant changes to the state are performed by `connect` and `disconnect` which themselves now use `synchronized`.
   
   Also, I can't find any other code that uses equivalent synchronization on the state.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ARTEMIS-3622 MQTT can deadlock on client cxn/discxn [activemq-artemis]

Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #4909:
URL: https://github.com/apache/activemq-artemis/pull/4909#discussion_r1608344664


##########
artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java:
##########
@@ -176,33 +174,27 @@ ServerSessionImpl createServerSession(String username, String password, String v
       return (ServerSessionImpl) serverSession;
    }
 
-   void disconnect(boolean failure) {
+   synchronized void disconnect(boolean failure) {
       if (session == null || session.getStopped()) {
          return;
       }
 
-      synchronized (session.getState()) {

Review Comment:
   I've looked through it carefully and I don't see any potential problems. The relevant changes to the state are performed by `connect` and `disconnect` which are themselves now use `synchronized`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ARTEMIS-3622 MQTT can deadlock on client cxn/discxn [activemq-artemis]

Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #4909:
URL: https://github.com/apache/activemq-artemis/pull/4909#discussion_r1608344664


##########
artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java:
##########
@@ -176,33 +174,27 @@ ServerSessionImpl createServerSession(String username, String password, String v
       return (ServerSessionImpl) serverSession;
    }
 
-   void disconnect(boolean failure) {
+   synchronized void disconnect(boolean failure) {
       if (session == null || session.getStopped()) {
          return;
       }
 
-      synchronized (session.getState()) {

Review Comment:
   I've looked through it carefully and I don't see any potential problems. The relevant changes to the state are performed by `connect` and `disconnect` which themselves now use `synchronized`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ARTEMIS-3622 MQTT can deadlock on client cxn/discxn [activemq-artemis]

Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #4909:
URL: https://github.com/apache/activemq-artemis/pull/4909#discussion_r1602019436


##########
artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java:
##########
@@ -176,33 +174,27 @@ ServerSessionImpl createServerSession(String username, String password, String v
       return (ServerSessionImpl) serverSession;
    }
 
-   void disconnect(boolean failure) {
+   synchronized void disconnect(boolean failure) {
       if (session == null || session.getStopped()) {
          return;
       }
 
-      synchronized (session.getState()) {

Review Comment:
   This seems fine in terms of protecting the connect+disconnect calls similar to before...but, are there other areas synchronising on and accessing or manipulating the session state that might no longer be protected as before that still need to be?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ARTEMIS-3622 MQTT can deadlock on client cxn/discxn [activemq-artemis]

Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr merged PR #4909:
URL: https://github.com/apache/activemq-artemis/pull/4909


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org