Skip to content

Commit

Permalink
[ISSUE #3099] Fix the incorrect judegment 'writePos - lastCommittedPo…
Browse files Browse the repository at this point in the history
…sition > commitLeastPages' in the method 'commit0' of class 'MappedFile' (#3125)
  • Loading branch information
xiaoyaofawai committed Jul 9, 2021
1 parent 2fc1148 commit 589e87c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions store/src/main/java/org/apache/rocketmq/store/MappedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public int commit(final int commitLeastPages) {
}
if (this.isAbleToCommit(commitLeastPages)) {
if (this.hold()) {
commit0(commitLeastPages);
commit0();
this.release();
} else {
log.warn("in commit, hold failed, commit offset = " + this.committedPosition.get());
Expand All @@ -317,11 +317,11 @@ public int commit(final int commitLeastPages) {
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);
Expand Down

0 comments on commit 589e87c

Please sign in to comment.