Skip to content

Commit

Permalink
Fix QueueEntry recycle problem. (#3747)
Browse files Browse the repository at this point in the history
Descriptions of the changes in this PR:
In the QueueEntry recycle, it only recycles itself to the object pool, but didn't reset some properties.
Like entry, cb, etc. We should reset the filed before recycles itself.
  • Loading branch information
horizonzy committed Feb 3, 2023
1 parent f6a7c06 commit 901f76c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ public void run() {
cbThreadPoolQueueSize.dec();
journalAddEntryStats.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueTime), TimeUnit.NANOSECONDS);
cb.writeComplete(0, ledgerId, entryId, null, ctx);
recycle();
callbackTime.addLatency(MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS);
recycle();
}

private final Handle<QueueEntry> recyclerHandle;
Expand All @@ -365,6 +365,14 @@ protected QueueEntry newObject(Recycler.Handle<QueueEntry> handle) {
};

private void recycle() {
this.entry = null;
this.cb = null;
this.ctx = null;
this.journalAddEntryStats = null;
this.journalCbQueuedLatency = null;
this.journalCbQueueSize = null;
this.cbThreadPoolQueueSize = null;
this.callbackTime = null;
recyclerHandle.recycle(this);
}
}
Expand Down

0 comments on commit 901f76c

Please sign in to comment.