BewareMyPower commented on code in PR #25110:
URL: https://github.com/apache/pulsar/pull/25110#discussion_r2672451559


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java:
##########
@@ -481,14 +481,15 @@ public void asyncOpen(final String name, final 
ManagedLedgerConfig config, final
                             public void initializeComplete() {
                                 log.info("[{}] Successfully initialize managed 
ledger", name);
                                 pendingInitializeLedgers.remove(name, 
pendingLedger);
-                                future.complete(newledger);
-
-                                // May need to update the cursor position
-                                
newledger.maybeUpdateCursorBeforeTrimmingConsumedLedger();
-                                // May need to trigger offloading
-                                if (config.isTriggerOffloadOnTopicLoad()) {
-                                    
newledger.maybeOffloadInBackground(NULL_OFFLOAD_PROMISE);
-                                }
+                                // May need to update the cursor position and 
wait them finished
+                                
newledger.maybeUpdateCursorBeforeTrimmingConsumedLedger().whenComplete((__, ex) 
-> {
+                                    // ignore ex since it is handled in 
maybeUpdateCursorBeforeTrimmingConsumedLedger
+                                    future.complete(newledger);
+                                    // May need to trigger offloading
+                                    if (config.isTriggerOffloadOnTopicLoad()) {
+                                        
newledger.maybeOffloadInBackground(NULL_OFFLOAD_PROMISE);
+                                    }
+                                });

Review Comment:
   This PR might have done many things. Is this change related to a specific 
flaky test?



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