liangyepianzhou commented on PR #20927:
URL: https://github.com/apache/pulsar/pull/20927#issuecomment-1717091753

   > > During the process of creating a subscription, when checking if the 
transaction pending has been initialized using return store.exists(PREFIX + 
path);, a connection failure error occurred while connecting to ZooKeeper. 
However, the created subscription continues to exist in the PersistentTopic, 
which causes subsequent retries to keep using the same subscription.
   > 
   > @liangyepianzhou In such a scenario, the "subscribe" command should be 
deemed unsuccessful. The PendingAck module, being a part of the system, should 
focus solely on cleaning up its own state and subsequently notifying the caller 
of the failure it encountered. Then the caller("subscribe") should cleanup it's 
own state.
   
   This process can happen in loading or creating persistent topics, and the 
method `createPersistentSubscription` does not concern the errors that happened 
in constructing PersistentSubscription. So it's not easy for us to fail the 
caller.
   ```java
       private PersistentSubscription createPersistentSubscription(String 
subscriptionName, ManagedCursor cursor,
               boolean replicated, Map<String, String> subscriptionProperties) {
           requireNonNull(topicCompactionService);
           if (isCompactionSubscription(subscriptionName)
                   && topicCompactionService instanceof 
PulsarTopicCompactionService pulsarTopicCompactionService) {
               CompactedTopicImpl compactedTopic = 
pulsarTopicCompactionService.getCompactedTopic();
               return new PulsarCompactorSubscription(this, compactedTopic, 
subscriptionName, cursor);
           } else {
               return new PersistentSubscription(this, subscriptionName, 
cursor, replicated, subscriptionProperties);
           }
       }
   ```
   
   We can just reload the subscription to load PendingAck again.
   Whether it is the broker initiating a retry or returning an exception to the 
client side, which then triggers a retry, the result is identical. Users are 
oblivious to this, as we do not throw retryable exceptions to the users.
   
   


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