hzh0425 commented on code in PR #4414:
URL: https://github.com/apache/rocketmq/pull/4414#discussion_r889765811
##########
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 等 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]