poorbarcode opened a new pull request, #25725:
URL: https://github.com/apache/pulsar/pull/25725

   ### Motivation
   
   If a producer is closed when its state is `RegisteringSchema`, it will not 
call `removeProducer`<sup>[1]</sup>. Eventually, it leads to a broker-side 
producer handle leak(Memory leak), and may cause such an error: `Producer with 
name 'xxx' is already connected to topic`. The issue will also lead to 
replicators being stuck.
   
   You can reproduce the issue with the two new tests
   
   
   - **[1]**: 
https://github.com/apache/pulsar/blob/v4.2.1/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L1243-L1247
   
   ```java
       @Override
       public synchronized CompletableFuture<Void> closeAsync() {
           //...
           //...
           if (cnx == null || currentState != State.Ready) {
               log.info("[{}] [{}] Closed Producer (not connected)", topic, 
producerName);
               closeAndClearPendingMessages();
               return CompletableFuture.completedFuture(null); // (Highlight) 
it returns without remove producer from broker-side.
           }
           //...
           //...
   }
   ```
   
   ### Modifications
   
   - fix the issue
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment


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