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 5132258db9 Fix epoch truncate (#9942)
5132258db9 is described below

commit 5132258db946e9741550c5d1076d605f60a1f2e3
Author: littleboy <[email protected]>
AuthorDate: Wed Dec 24 09:31:42 2025 +0800

    Fix epoch truncate (#9942)
---
 .../apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
 
b/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
index 176c25a96f..3dd14f4e35 100644
--- 
a/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
+++ 
b/store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
@@ -463,8 +463,11 @@ public class AutoSwitchHAClient extends ServiceThread 
implements HAClient {
                 LOGGER.error("Failed to truncate slave log to {}", 
truncateOffset);
                 return false;
             }
-            this.epochCache.truncateSuffixByOffset(truncateOffset);
-            LOGGER.info("Truncate slave log to {} success, change to transfer 
state", truncateOffset);
+            final long maxPhyOffset = this.messageStore.getMaxPhyOffset();
+            if (truncateOffset < maxPhyOffset) {
+                this.epochCache.truncateSuffixByOffset(truncateOffset);
+                LOGGER.info("Truncate slave log to {} success, change to 
transfer state", truncateOffset);
+            }
             changeCurrentState(HAConnectionState.TRANSFER);
             this.currentReportedOffset = truncateOffset;
         }

Reply via email to