diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java index 741d324e3c2..e5b210d4cae 100644 --- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java +++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java @@ -1634,13 +1634,15 @@ private void swapRequests() { private void doCommit() { if (!this.requestsRead.isEmpty()) { for (GroupCommitRequest req : this.requestsRead) { - boolean flushOK = false; - for (int i = 0; i < 1000; i++) { + boolean flushOK = CommitLog.this.mappedFileQueue.getFlushedWhere() >= req.getNextOffset(); + for (int i = 0; i < 1000 && !flushOK; i++) { CommitLog.this.mappedFileQueue.flush(0); flushOK = CommitLog.this.mappedFileQueue.getFlushedWhere() >= req.getNextOffset(); if (flushOK) { break; } else { + // When transientStorePoolEnable is true, the messages in writeBuffer may not be committed + // to pageCache very quickly, and flushOk here may almost be false. try { Thread.sleep(1); } catch (InterruptedException ignored) {