Skip to content

Commit

Permalink
release ledgerHandler when no missing fragments in checkAllLedgers (#…
Browse files Browse the repository at this point in the history
…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;
  • Loading branch information
Nicklee007 authored Mar 29, 2023
1 parent e440132 commit 164417a
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,19 @@ public void operationComplete(int rc, Set<LedgerFragment> fragments) {
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);
}
Expand Down

0 comments on commit 164417a

Please sign in to comment.