lhotari commented on pull request #11884:
URL: https://github.com/apache/pulsar/pull/11884#issuecomment-914076442


   Several comments have been about using a concurrent queue implementation. I 
don't think that is necessary as long as the access of the queue is properly 
synchronized. The solution in this PR demonstrates in a unit test how the 
ConcurrentModificationException can happen in a single thread. When using an 
ordinary ArrayDeque the test would fail. 
   
   The root cause of #11783 is that while the current thread is executing the 
action in the forEach block, the callback code might try to add a new OpSendMsg 
entry in the calling thread.
   
   Some locations:
   
   
https://github.com/apache/pulsar/blob/d86db3f4ec4fb6bd04216a123cde2fee5c43f9d9/pulsar-
   
client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L886-L891
   
   
https://github.com/apache/pulsar/blob/d86db3f4ec4fb6bd04216a123cde2fee5c43f9d9/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L1638-L1657
   
   I guess it's a valid case that after failing all pending messages the client 
code is allowed to access the producer in the callback to send more messages. 
(there are more details in #11783) 
   
   @merlimat @codelipenghui Does the approach in this PR make sense, to 
postpone elements added while the forEach loop is in progress?


-- 
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: commits-unsubscr...@pulsar.apache.org

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


Reply via email to