You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/10/13 14:20:33 UTC

[GitHub] [activemq] mattrpav opened a new pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

mattrpav opened a new pull request #720:
URL: https://github.com/apache/activemq/pull/720


   …event CME


-- 
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



[GitHub] [activemq] mattrpav commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
mattrpav commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-974287550


   Internal tests validation:
   500M+ messages sent to 1 queue
   400x producers
   400x consumers
   1-transaction-per-message commit strategy


-- 
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



[GitHub] [activemq] mattrpav commented on a change in pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
mattrpav commented on a change in pull request #720:
URL: https://github.com/apache/activemq/pull/720#discussion_r728150454



##########
File path: activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
##########
@@ -226,4 +232,10 @@ public boolean isRollbackOnly() {
         return rollackOnlyCause != null;
     }
 
+    protected ArrayList<Synchronization> getSynchronizationsCopy() {

Review comment:
       > I'm not really a fan of this solution, there's a couple other approaches you could take.
   > 
   > First, If you are going to copy anyways then why not just use a CopyOnWriteArrayList and not have to synchronize and do all the manual copying?
   > 
   > Another option that might be better is just do what JB said and synchronized the list. Then you also need to synchronize when iterating as well and this would avoid the expensive copy as wrapping with with Synchronized doesn't make iterating thread safe. It should be rare for 2 threads to be touching the Transaction object usually so synchronizing should be fine most of the time.
   > 
   > You also may be able to find another collection type that is concurrent that could be used but for list implementations there aren't really any.
   
   Thanks for the quick review. Agree, not in love with a lot of the approach options. I was hoping to thread the needle around not having to synchronize on all operations, but yeah copies are not great either.
   
   Given the iterator-not-synchronized problem seems that synchronized(synchronizations) {} is best approach 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



[GitHub] [activemq] mattrpav commented on a change in pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
mattrpav commented on a change in pull request #720:
URL: https://github.com/apache/activemq/pull/720#discussion_r728150454



##########
File path: activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
##########
@@ -226,4 +232,10 @@ public boolean isRollbackOnly() {
         return rollackOnlyCause != null;
     }
 
+    protected ArrayList<Synchronization> getSynchronizationsCopy() {

Review comment:
       > I'm not really a fan of this solution, there's a couple other approaches you could take.
   > 
   > First, If you are going to copy anyways then why not just use a CopyOnWriteArrayList and not have to synchronize and do all the manual copying?
   > 
   > Another option that might be better is just do what JB said and synchronized the list. Then you also need to synchronize when iterating as well and this would avoid the expensive copy as wrapping with with Synchronized doesn't make iterating thread safe. It should be rare for 2 threads to be touching the Transaction object usually so synchronizing should be fine most of the time.
   > 
   > You also may be able to find another collection type that is concurrent that could be used but for list implementations there aren't really any.
   
   Thanks for the quick review. Agree, not in love with a lot of the approach options. I was hoping to thread the needle around not having to synchronize on all operations, but yeah copies are not great either.
   
   Given the iterator-not-synchronized problem seems that synchronized(synchronizations) {} is best approach 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



[GitHub] [activemq] jbonofre commented on a change in pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
jbonofre commented on a change in pull request #720:
URL: https://github.com/apache/activemq/pull/720#discussion_r728136488



##########
File path: activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
##########
@@ -226,4 +232,10 @@ public boolean isRollbackOnly() {
         return rollackOnlyCause != null;
     }
 
+    protected ArrayList<Synchronization> getSynchronizationsCopy() {

Review comment:
       Maybe it's easier/smaller to use `Collections.synchronizedList(new ArrayList<Object>());` instead of a method wrapping with sync ?




-- 
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



[GitHub] [activemq] mattrpav merged pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
mattrpav merged pull request #720:
URL: https://github.com/apache/activemq/pull/720


   


-- 
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



[GitHub] [activemq] jbonofre commented on a change in pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
jbonofre commented on a change in pull request #720:
URL: https://github.com/apache/activemq/pull/720#discussion_r728136488



##########
File path: activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
##########
@@ -226,4 +232,10 @@ public boolean isRollbackOnly() {
         return rollackOnlyCause != null;
     }
 
+    protected ArrayList<Synchronization> getSynchronizationsCopy() {

Review comment:
       Maybe it's easier/smaller to use `Collections.synchronizedList(new ArrayList<Object>());` instead of a method wrapping with sync ?




-- 
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



[GitHub] [activemq] cshannon commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
cshannon commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-942390816


   Probably, synchronization is most likely better than copying since that is pretty expensive and synchronizing on the object when it's not contended is not very expensive


-- 
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



[GitHub] [activemq] cshannon commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
cshannon commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-942380306






-- 
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



[GitHub] [activemq] cshannon commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
cshannon commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-942380306


   I'm not really a fan of this solution, there's a couple other approaches you could take.
   
   First, If you are going to copy anyways then why not just use a CopyOnWriteArrayList and not have to synchronize and do all the manual copying?
   
   Another option that might be better is just do what JB said and synchronized the list. Then you also need to synchronize when iterating as well and this would avoid the expensive copy as wrapping with with Synchronized doesn't make iterating thread safe. It should be rare for 2 threads to be touching the Transaction object usually so synchronizing should be fine most of the time.
   
   You also may be able to find another collection type that is concurrent that could be used but for list implementations there aren't really any.


-- 
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



[GitHub] [activemq] mattrpav commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
mattrpav commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-942387489


   @jbonofre @cshannon Thanks for the quick review. Agree, not in love with a lot of the approach options. I was hoping to thread the needle around not having to synchronize on all operations, but yeah copies are not great either.
   
   Given the iterator-not-synchronized problem seems that synchronized(synchronizations) {} is best approach 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



[GitHub] [activemq] mattrpav commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

Posted by GitBox <gi...@apache.org>.
mattrpav commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-942387489


   @jbonofre @cshannon Thanks for the quick review. Agree, not in love with a lot of the approach options. I was hoping to thread the needle around not having to synchronize on all operations, but yeah copies are not great either.
   
   Given the iterator-not-synchronized problem seems that synchronized(synchronizations) {} is best approach 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