You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by ch...@apache.org on 2023/02/03 02:34:48 UTC

[bookkeeper] branch master updated: Fix QueueEntry recycle problem. (#3747)

This is an automated email from the ASF dual-hosted git repository.

chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 901f76ce4c Fix QueueEntry recycle problem. (#3747)
901f76ce4c is described below

commit 901f76ce4c4f9f771363424dbb60da4d590ad122
Author: Yan Zhao <ho...@apache.org>
AuthorDate: Fri Feb 3 10:34:41 2023 +0800

    Fix QueueEntry recycle problem. (#3747)
    
    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.
---
 .../src/main/java/org/apache/bookkeeper/bookie/Journal.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index fff4644522..3942e7662a 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -347,8 +347,8 @@ public class Journal extends BookieCriticalThread implements CheckpointSource {
             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;
@@ -365,6 +365,14 @@ public class Journal extends BookieCriticalThread implements CheckpointSource {
         };
 
         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);
         }
     }