RongtongJin commented on code in PR #4414:
URL: https://github.com/apache/rocketmq/pull/4414#discussion_r889763807


##########
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java:
##########
@@ -162,15 +165,13 @@ public Set<String> maybeShrinkInSyncStateSet() {
         final Set<String> currentSyncStateSet = getSyncStateSet();
         final HashSet<String> newSyncStateSet = new 
HashSet<>(currentSyncStateSet);
         final long haMaxTimeSlaveNotCatchup = 
this.defaultMessageStore.getMessageStoreConfig().getHaMaxTimeSlaveNotCatchup();
-        for (HAConnection haConnection : this.connectionList) {
-            final AutoSwitchHAConnection connection = (AutoSwitchHAConnection) 
haConnection;
-            final String slaveAddress = connection.getSlaveAddress();
+        for (Map.Entry<String, Long> next: 
this.connectionCaughtUpTimeTable.entrySet()) {
+            final String slaveAddress = next.getKey();
             if (currentSyncStateSet.contains(slaveAddress)) {
-                if (connection.getSlaveAckOffset() < 0 || 
this.defaultMessageStore.getMaxPhyOffset() == connection.getSlaveAckOffset()) {
-                    continue;
-                }
-                if ((System.currentTimeMillis() - 
connection.getLastCatchUpTimeMs()) > haMaxTimeSlaveNotCatchup) {
+                final Long lastCaughtUpTimeMs = 
this.connectionCaughtUpTimeTable.get(slaveAddress);
+                if ((System.currentTimeMillis() - lastCaughtUpTimeMs) > 
haMaxTimeSlaveNotCatchup) {
                     newSyncStateSet.remove(slaveAddress);
+                    this.connectionCaughtUpTimeTable.remove(slaveAddress);
                 }

Review Comment:
   
这里存在这样一种情况:connectionCaughtUpTimeTable和newSyncStateSet把slave移除了,但newSyncStateSet上报没有成功,所以syncStateSet并没有修改成功。但下次shrink的时候由于connectionCaughtUpTimeTable已经移除了,syncStateSet不会移除了。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to