You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by ch...@apache.org on 2023/03/29 11:18:26 UTC

[bookkeeper] 02/03: release ledgerHandler when no missing fragments in checkAllLedgers (#3888)

This is an automated email from the ASF dual-hosted git repository.

chenhang pushed a commit to branch branch-4.16
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit 9b5a8106b5129aab1f47be70a8ed344f871c8466
Author: lixinyang <84...@users.noreply.github.com>
AuthorDate: Wed Mar 29 09:44:45 2023 +0800

    release ledgerHandler when no missing fragments in checkAllLedgers (#3888)
    
    ### Motivation
    In checkAllLedgers when the ledger no missing fragments, will miss invoke` lh.closeAsync()` to close ledgerHandler, which cause autorecovery not invoke `unregisterLedgerMetadataListener` to release ledger metadata listeners. Heap memory be used too much and maybe will cause OOM;
    
    <img width="1567" alt="image" src="https://user-images.githubusercontent.com/84127069/227937422-1113af68-9bf3-4466-97fa-d9b7cc5d72be.png">
    
    ### Changes
    1.  Invoke` lh.closeAsync()` when no missing fragments;
    
    (cherry picked from commit 164417afc2474cbf4ba51e7cb57206b0eeb7d424)
---
 .../replication/AuditorCheckAllLedgersTask.java    | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorCheckAllLedgersTask.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorCheckAllLedgersTask.java
index 73ca36cd75..f6b7a6f36e 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorCheckAllLedgersTask.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorCheckAllLedgersTask.java
@@ -267,19 +267,19 @@ public class AuditorCheckAllLedgersTask extends AuditorTask {
                 if (bookies.isEmpty()) {
                     // no missing fragments
                     callback.processResult(BKException.Code.OK, null, null);
-                    return;
+                } else {
+                    publishSuspectedLedgersAsync(bookies.stream().map(BookieId::toString).collect(Collectors.toList()),
+                            Sets.newHashSet(lh.getId())
+                    ).whenComplete((result, cause) -> {
+                        if (null != cause) {
+                            LOG.error("Auditor exception publishing suspected ledger {} with lost bookies {}",
+                                    lh.getId(), bookies, cause);
+                            callback.processResult(BKException.Code.ReplicationException, null, null);
+                        } else {
+                            callback.processResult(BKException.Code.OK, null, null);
+                        }
+                    });
                 }
-                publishSuspectedLedgersAsync(bookies.stream().map(BookieId::toString).collect(Collectors.toList()),
-                        Sets.newHashSet(lh.getId())
-                ).whenComplete((result, cause) -> {
-                    if (null != cause) {
-                        LOG.error("Auditor exception publishing suspected ledger {} with lost bookies {}",
-                                lh.getId(), bookies, cause);
-                        callback.processResult(BKException.Code.ReplicationException, null, null);
-                    } else {
-                        callback.processResult(BKException.Code.OK, null, null);
-                    }
-                });
             } else {
                 callback.processResult(rc, null, null);
             }