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.

(cherry picked from commit 901f76c)
  • Loading branch information
horizonzy authored and zymap committed Feb 16, 2023
1 parent fcff85b commit f3eadd6
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ public void run() {
cbThreadPoolQueueSize.dec();
journalAddEntryStats.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueTime), TimeUnit.NANOSECONDS);
cb.writeComplete(0, ledgerId, entryId, null, ctx);
recycle();
callbackTime.add(MathUtils.elapsedNanos(startTime));
recycle();
}

private final Handle<QueueEntry> recyclerHandle;
Expand All @@ -366,6 +366,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 f3eadd6

Please sign in to comment.