poorbarcode commented on PR #21203:
URL: https://github.com/apache/pulsar/pull/21203#issuecomment-1734826893

   Add a context:
   
   This PR is trying to fix the issue below
   - `Close replication task` and `Start producer of replicator` were executed 
at the same time.
   - `Start producer of replicator` runs after `Close replication task`
   - If the producer started failed, retry; if the next start also failed, 
retry again....loop.
   
   Once the producer creates success, the loop will be stopped. Explain: After 
the cursor was closed. The method `readEntries | readMoreEntries` will get a 
`CursorAlreadyClosedException`, then the producer will be closed. see 
https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentReplicator.java#L440
   
   ```java
   if (exception instanceof CursorAlreadyClosedException) {
       log.error("[{}] Error reading entries because replicator is"
                       + " already deleted and cursor is already closed {}, 
({})",
               replicatorId, ctx, exception.getMessage(), exception);
       // replicator is already deleted and cursor is already closed so, 
producer should also be stopped
       closeProducerAsync();
       return;
   }
   ```
   
   So this PR only trying to fix the scenario that the producer always creates 
fails.


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