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 85d7bb3ecf Fix bug of negative JournalQueueSize (#4077)
85d7bb3ecf is described below

commit 85d7bb3ecf14301f36a51225d5ecce42b614bc44
Author: XLzed <[email protected]>
AuthorDate: Thu Oct 26 15:50:56 2023 +0800

    Fix bug of negative JournalQueueSize (#4077)
    
    ### Motivation
    
    While shouldRolloverJournal is true,the QueueEntry qe is not added to the 
toFlush queue but we decrease the JournalQueueSize incorrectly.
    
    ### Changes
    
    Decrease the JournalQueueSize after correct NonNull check of qe.
---
 .../src/main/java/org/apache/bookkeeper/bookie/Journal.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

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 9735e13717..000a013881 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
@@ -1033,15 +1033,9 @@ public class Journal extends BookieCriticalThread 
implements CheckpointSource {
                     if (localQueueEntriesLen > 0) {
                         qe = localQueueEntries[localQueueEntriesIdx];
                         localQueueEntries[localQueueEntriesIdx++] = null;
-                        journalStats.getJournalQueueSize().dec();
-                        journalStats.getJournalQueueStats()
-                                
.registerSuccessfulEvent(MathUtils.elapsedNanos(qe.enqueueTime), 
TimeUnit.NANOSECONDS);
                     }
-                } else {
-                    journalStats.getJournalQueueSize().dec();
-                    journalStats.getJournalQueueStats()
-                            
.registerSuccessfulEvent(MathUtils.elapsedNanos(qe.enqueueTime), 
TimeUnit.NANOSECONDS);
                 }
+
                 if (numEntriesToFlush > 0) {
                     boolean shouldFlush = false;
                     // We should issue a forceWrite if any of the three 
conditions below holds good
@@ -1161,6 +1155,11 @@ public class Journal extends BookieCriticalThread 
implements CheckpointSource {
                 if (qe == null) { // no more queue entry
                     continue;
                 }
+
+                journalStats.getJournalQueueSize().dec();
+                journalStats.getJournalQueueStats()
+                        
.registerSuccessfulEvent(MathUtils.elapsedNanos(qe.enqueueTime), 
TimeUnit.NANOSECONDS);
+
                 if ((qe.entryId == BookieImpl.METAENTRY_ID_LEDGER_EXPLICITLAC)
                         && (journalFormatVersionToWrite < JournalChannel.V6)) {
                     /*

Reply via email to