You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2022/09/13 12:15:41 UTC
[rocketmq] branch develop updated: [ISSUE #5040] Optimize AutoSwitchHAService#truncateInvalidMsg logic (#5041)
This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 2298d9bf0 [ISSUE #5040] Optimize AutoSwitchHAService#truncateInvalidMsg logic (#5041)
2298d9bf0 is described below
commit 2298d9bf08975a142d3b079267935ff1eebe3576
Author: mxsm <lj...@gmail.com>
AuthorDate: Tue Sep 13 20:15:32 2022 +0800
[ISSUE #5040] Optimize AutoSwitchHAService#truncateInvalidMsg logic (#5041)
---
.../rocketmq/store/ha/autoswitch/AutoSwitchHAService.java | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java
index 49794c28a..e0ba59369 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java
@@ -354,10 +354,9 @@ public class AutoSwitchHAService extends DefaultHAService {
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;
@@ -369,10 +368,8 @@ public class AutoSwitchHAService extends DefaultHAService {
int readSize = 0;
while (readSize < result.getSize()) {
DispatchRequest dispatchRequest = this.defaultMessageStore.getCommitLog().checkMessageAndReturnSize(result.getByteBuffer(), false, false);
-
- int size = dispatchRequest.getMsgSize();
-
if (dispatchRequest.isSuccess()) {
+ int size = dispatchRequest.getMsgSize();
if (size > 0) {
reputFromOffset += size;
readSize += size;
@@ -388,7 +385,7 @@ public class AutoSwitchHAService extends DefaultHAService {
} finally {
result.release();
}
- }
+ } while (reputFromOffset < this.defaultMessageStore.getMaxPhyOffset() && doNext);
LOGGER.info("Truncate commitLog to {}", reputFromOffset);
this.defaultMessageStore.truncateDirtyFiles(reputFromOffset);