Skip to content

Commit

Permalink
Fixed used after recycle issue in OpAddEntry (apache#12103)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Sep 22, 2021
1 parent 0a1ae98 commit 3c4597d
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,19 @@ void handleAddTimeoutFailure(final LedgerHandle ledger, Object ctx) {
/**
* It handles add failure on the given ledger. it can be triggered when add-entry fails or times out.
*
* @param ledger
* @param lh
*/
void handleAddFailure(final LedgerHandle ledger) {
void handleAddFailure(final LedgerHandle lh) {
// If we get a write error, we will try to create a new ledger and re-submit the pending writes. If the
// ledger creation fails (persistent bk failure, another instanche owning the ML, ...), then the writes will
// ledger creation fails (persistent bk failure, another instance owning the ML, ...), then the writes will
// be marked as failed.
ml.mbean.recordAddEntryError();
ManagedLedgerImpl finalMl = this.ml;
finalMl.mbean.recordAddEntryError();

ml.getExecutor().executeOrdered(ml.getName(), SafeRun.safeRun(() -> {
finalMl.getExecutor().executeOrdered(finalMl.getName(), SafeRun.safeRun(() -> {
// Force the creation of a new ledger. Doing it in a background thread to avoid acquiring ML lock
// from a BK callback.
ml.ledgerClosed(ledger);
finalMl.ledgerClosed(lh);
}));
}

Expand Down

0 comments on commit 3c4597d

Please sign in to comment.