From 589e87c278147ee17cbcaac334d8558a8ef98ea2 Mon Sep 17 00:00:00 2001 From: xiaoyaofawai Date: Fri, 9 Jul 2021 13:40:02 +0800 Subject: [PATCH] [ISSUE #3099] Fix the incorrect judegment 'writePos - lastCommittedPosition > commitLeastPages' in the method 'commit0' of class 'MappedFile' (#3125) --- .../src/main/java/org/apache/rocketmq/store/MappedFile.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java index b5bdc776..25f0e393 100644 --- a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java +++ b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java @@ -301,7 +301,7 @@ public class MappedFile extends ReferenceResource { } if (this.isAbleToCommit(commitLeastPages)) { if (this.hold()) { - commit0(commitLeastPages); + commit0(); this.release(); } else { log.warn("in commit, hold failed, commit offset = " + this.committedPosition.get()); @@ -317,11 +317,11 @@ public class MappedFile extends ReferenceResource { return this.committedPosition.get(); } - protected void commit0(final int commitLeastPages) { + protected void commit0() { int writePos = this.wrotePosition.get(); int lastCommittedPosition = this.committedPosition.get(); - if (writePos - lastCommittedPosition > commitLeastPages) { + if (writePos - lastCommittedPosition > 0) { try { ByteBuffer byteBuffer = writeBuffer.slice(); byteBuffer.position(lastCommittedPosition); -- GitLab