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

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


The following commit(s) were added to refs/heads/master by this push:
     new 94e1341d1e2 [improve][broker] Optimize high CPU usage when consuming 
from topics with ongoing txn (#23189)
94e1341d1e2 is described below

commit 94e1341d1e299bc93b809fc3046b70390de43592
Author: Cong Zhao <[email protected]>
AuthorDate: Tue Aug 20 23:32:22 2024 +0800

    [improve][broker] Optimize high CPU usage when consuming from topics with 
ongoing txn (#23189)
---
 .../main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
index f99ee957e02..e808c31bc89 100644
--- 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
+++ 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
@@ -953,7 +953,7 @@ public class ManagedCursorImpl implements ManagedCursor {
 
         int numberOfEntriesToRead = applyMaxSizeCap(maxEntries, maxSizeBytes);
 
-        if (hasMoreEntries()) {
+        if (hasMoreEntries() && maxPosition.compareTo(readPosition) >= 0) {
             // If we have available entries, we can read them immediately
             if (log.isDebugEnabled()) {
                 log.debug("[{}] [{}] Read entries immediately", 
ledger.getName(), name);

Reply via email to