Skip to content

[Bug] The judge logic maybe exist problem in org.apache.rocketmq.store.MappedFile#commit0 #2563

@horizonzy

Description

@horizonzy

BUG REPORT

  1. Please describe the issue you observed:
    The code as follow:
    protected void commit0(final int commitLeastPages) {
        int writePos = this.wrotePosition.get();
        int lastCommittedPosition = this.committedPosition.get();

        if (writePos - lastCommittedPosition > commitLeastPages) {
            try {
                ByteBuffer byteBuffer = writeBuffer.slice();
                byteBuffer.position(lastCommittedPosition);
                byteBuffer.limit(writePos);
                this.fileChannel.position(lastCommittedPosition);
                this.fileChannel.write(byteBuffer);
                this.committedPosition.set(writePos);
            } catch (Throwable e) {
                log.error("Error occurred when commit data to FileChannel.", e);
            }
        }
    }

if (writePos - lastCommittedPosition > commitLeastPages) should be
if (writePos - lastCommittedPosition > commitLeastPages * OS_PAGE_SIZE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions