Skip to content

Commit

Permalink
Release OpAddEntry.data when entry is copied and discarded (#10773)
Browse files Browse the repository at this point in the history
Fixes #10738

There's a ByteBuf leak that happens in ledger rollover. The repro case in #10738 reproduces some Netty ByteBuf leaks that are detected by the Netty Leak detector.

Release `OpAddEntry.data` when the original entry is copied and discarded

This PR was split out of PR #10755 which was closed without merging.
  • Loading branch information
lhotari committed Jun 2, 2021
1 parent 4372b49 commit 121305f
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import io.netty.buffer.Unpooled;
import io.netty.util.Recycler;
import io.netty.util.Recycler.Handle;
import io.netty.util.ReferenceCountUtil;
import java.time.Clock;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -1399,6 +1400,8 @@ public synchronized void updateLedgersIdsComplete(Stat stat) {
if (existsOp.ledger != null) {
existsOp.close();
existsOp = OpAddEntry.create(existsOp.ml, existsOp.data, existsOp.callback, existsOp.ctx);
// release the extra retain
ReferenceCountUtil.release(existsOp.data);
}
existsOp.setLedger(currentLedger);
pendingAddEntries.add(existsOp);
Expand Down

0 comments on commit 121305f

Please sign in to comment.