eolivelli commented on a change in pull request #11494:
URL: https://github.com/apache/pulsar/pull/11494#discussion_r685727047



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/pendingack/impl/MLPendingAckStoreProvider.java
##########
@@ -47,40 +48,66 @@
                     new TransactionPendingAckStoreProviderException("The 
subscription is null."));
             return pendingAckStoreFuture;
         }
-
         PersistentTopic originPersistentTopic = (PersistentTopic) 
subscription.getTopic();
         String pendingAckTopicName = MLPendingAckStore
                 
.getTransactionPendingAckStoreSuffix(originPersistentTopic.getName(), 
subscription.getName());
-
         originPersistentTopic.getBrokerService().getManagedLedgerFactory()
-                
.asyncOpen(TopicName.get(pendingAckTopicName).getPersistenceNamingEncoding(),
-                        originPersistentTopic.getManagedLedger().getConfig(),
-                        new AsyncCallbacks.OpenLedgerCallback() {
-                            @Override
-                            public void openLedgerComplete(ManagedLedger 
ledger, Object ctx) {
-                                
ledger.asyncOpenCursor(MLPendingAckStore.getTransactionPendingAckStoreCursorName(),
-                                        InitialPosition.Earliest, new 
AsyncCallbacks.OpenCursorCallback() {
-                                            @Override
-                                            public void 
openCursorComplete(ManagedCursor cursor, Object ctx) {
-                                                pendingAckStoreFuture
-                                                        .complete(new 
MLPendingAckStore(ledger, cursor,
-                                                                
subscription.getCursor()));
-                                            }
+                .asyncExists(TopicName.get(pendingAckTopicName)
+                        .getPersistenceNamingEncoding()).thenAccept(exist -> {
+            TopicName topicName;
+            if (exist) {
+                topicName = TopicName.get(pendingAckTopicName);
+            } else {
+                topicName = TopicName.get(originPersistentTopic.getName());
+            }
+            originPersistentTopic.getBrokerService()
+                    .getManagedLedgerConfig(topicName).thenAccept(config -> {
+                config.setCreateIfMissing(true);
+                
originPersistentTopic.getBrokerService().getManagedLedgerFactory()
+                        
.asyncOpen(TopicName.get(pendingAckTopicName).getPersistenceNamingEncoding(),
+                                config, new 
AsyncCallbacks.OpenLedgerCallback() {
+                                    @Override
+                                    public void 
openLedgerComplete(ManagedLedger ledger, Object ctx) {
+                                        ledger.asyncOpenCursor(
+                                                
MLPendingAckStore.getTransactionPendingAckStoreCursorName(),
+                                                InitialPosition.Earliest, new 
AsyncCallbacks.OpenCursorCallback() {
+                                                    @Override
+                                                    public void 
openCursorComplete(ManagedCursor cursor, Object ctx) {
+                                                        pendingAckStoreFuture
+                                                                .complete(new 
MLPendingAckStore(ledger, cursor,
+                                                                        
subscription.getCursor()));
+                                                        log.info("{},{} open 
MLPendingAckStore cursor success",

Review comment:
       probably this logger should be moved to level `debug`




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