-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix autoRecover memory leak. #3361
Fix autoRecover memory leak. #3361
Conversation
c727699
to
4cd2d4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to close the ledger handle in Auditor#checkAllLedgers() to unregister the listener.
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
Lines 1333 to 1345 in 677ccec
localAdmin.asyncOpenLedgerNoRecovery(ledgerId, (rc, lh, ctx) -> { | |
openLedgerNoRecoverySemaphore.release(); | |
if (Code.OK == rc) { | |
checker.checkLedger(lh, | |
// the ledger handle will be closed after checkLedger is done. | |
new ProcessLostFragmentsCb(lh, callback), | |
conf.getAuditorLedgerVerificationPercentage()); | |
// we collect the following stats to get a measure of the | |
// distribution of a single ledger within the bk cluster | |
// the higher the number of fragments/bookies, the more distributed it is | |
numFragmentsPerLedger.registerSuccessfulValue(lh.getNumFragments()); | |
numBookiesPerLedger.registerSuccessfulValue(lh.getNumBookies()); | |
numLedgersChecked.inc(); |
In ProcessLostFragmentsCb, it will close it. |
// unregister the listener | ||
ledgerManager.unregisterLedgerMetadataListener(ledgerId, listener); | ||
assertFalse(ledgerManager.listeners.containsKey(ledgerId)); | ||
assertFalse(watchers.containsKey(ledgerStr)); | ||
verify(mockZk, times(1)).removeWatches(any(String.class), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify(mockZk, times(1)).removeWatches(any(String.class), | |
verify(mockZk, times(1)).removeWatches(eq(getLedgerPath(ledgerId)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good suggestion. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@eolivelli @dlg99 Would you like to help to review this PR? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch !
@dlg99 this may explain some problems you have seen in production
|
||
@Override | ||
public void run() { | ||
Set<LedgerMetadataListener> listeners = AbstractZkLedgerManager.this.listeners.get(ledgerId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is running in the same thread of "unregisterLedgerMetadataListener"
why do you need a inner class ? can't we simply code this as a regular Java method ?
private void cancelLedgerWatchers(long ledgerId) {
....
}
and call it from unregisterLedgerMetadataListener ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow the origin code style. See ReadLedgerMetadataTask
.
@eolivelli Could you please take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@hangc0276 please cherry pick to active branches (4.14, 4.15) |
@eolivelli sure. |
(cherry picked from commit da1b29a)
(cherry picked from commit da1b29a)
(cherry picked from commit da1b29a)
Descriptions of the changes in this PR:
fixes-#3360