You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/05 14:35:35 UTC

[GitHub] [pulsar] hangc0276 commented on a diff in pull request #17228: [fix][ml] refresh the ledgers map when the offload complete failed

hangc0276 commented on code in PR #17228:
URL: https://github.com/apache/pulsar/pull/17228#discussion_r962954110


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -2377,41 +2409,51 @@ private void maybeOffload(CompletableFuture<PositionImpl> finalPromise) {
                     && config.getLedgerOffloader().getOffloadPolicies() != null
                     && config.getLedgerOffloader().getOffloadPolicies().getManagedLedgerOffloadThresholdInBytes()
                     != null) {
-                long threshold = config.getLedgerOffloader().getOffloadPolicies()
-                        .getManagedLedgerOffloadThresholdInBytes();
-
-                long sizeSummed = 0;
-                long alreadyOffloadedSize = 0;
-                long toOffloadSize = 0;
-
                 ConcurrentLinkedDeque<LedgerInfo> toOffload = new ConcurrentLinkedDeque<>();
-
-                // go through ledger list from newest to oldest and build a list to offload in oldest to newest order
-                for (Map.Entry<Long, LedgerInfo> e : ledgers.descendingMap().entrySet()) {
-                    long size = e.getValue().getSize();
-                    sizeSummed += size;
-                    boolean alreadyOffloaded = e.getValue().hasOffloadContext()
+                CompletableFuture<Void> refreshFuture = new CompletableFuture<>();
+                if (lastOffloadCompleteFailed && !refreshedIfOffloadCompleteFailed) {
+                    refreshFuture = refreshLedgersInfo();
+                } else {
+                    refreshFuture.complete(null);
+                }
+                refreshFuture.whenComplete((unused, throwable) -> {
+                    if (throwable != null) {
+                        log.error("Failed to refresh the ledger info list", throwable);
+                        unlockingPromise.completeExceptionally(throwable);

Review Comment:
   +1



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org