sandeep-mst commented on code in PR #25207:
URL: https://github.com/apache/pulsar/pull/25207#discussion_r2762409297


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java:
##########
@@ -2298,11 +2304,16 @@ public void run(Timeout timeout) throws Exception {
      * This fails and clears the pending messages with the given exception. 
This method should be called from within the
      * ProducerImpl object mutex.
      */
-    private synchronized void failPendingMessages(ClientCnx cnx, 
PulsarClientException ex) {
+    @VisibleForTesting
+    synchronized void failPendingMessages(ClientCnx cnx, PulsarClientException 
ex) {

Review Comment:
   We do not access `pendingMessages` without the monitor lock.
   
   Even though, it has monitor lock this method is executed by a timer thread 
and when 
[op.sendComplete(ex)](https://github.com/cognitree/pulsar/blob/cab92f0164947e3cbb0da1a014951561f1599add/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L2315)
 is called within that method it switches to client logic where on the same 
thread they can send a retry message synchronously (`producer.sendAsync`) which 
will get enqueued into the pendingMessages 
[here](https://github.com/apache/pulsar/blob/cab92f0164947e3cbb0da1a014951561f1599add/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L2468).
 
   
   So, monitor lock is not preventing the issue from occurring because of 
reentrancy as it's the same thread holding the lock.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to