Skip to content

Commit

Permalink
[ISSUE #5040] Optimize AutoSwitchHAService#truncateInvalidMsg logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsm committed Sep 10, 2022
1 parent f8bf7bd commit d40c6bf
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,9 @@ public long truncateInvalidMsg() {
return -1;
}

long reputFromOffset = this.defaultMessageStore.getMaxPhyOffset() - dispatchBehind;

boolean doNext = true;
while (reputFromOffset < this.defaultMessageStore.getMaxPhyOffset() && doNext) {
long reputFromOffset = this.defaultMessageStore.getMaxPhyOffset() - dispatchBehind;
do {
SelectMappedBufferResult result = this.defaultMessageStore.getCommitLog().getData(reputFromOffset);
if (result == null) {
break;
Expand Down Expand Up @@ -388,7 +387,7 @@ public long truncateInvalidMsg() {
} finally {
result.release();
}
}
} while (reputFromOffset < this.defaultMessageStore.getMaxPhyOffset() && doNext);

LOGGER.info("Truncate commitLog to {}", reputFromOffset);
this.defaultMessageStore.truncateDirtyFiles(reputFromOffset);
Expand Down

0 comments on commit d40c6bf

Please sign in to comment.