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


##########
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java:
##########
@@ -258,12 +269,38 @@ public void maybeExpandInSyncStateSet(final String 
slaveAddress, final long slav
             final EpochEntry currentLeaderEpoch = this.epochCache.lastEntry();
             if (slaveMaxOffset >= currentLeaderEpoch.getStartOffset()) {
                 currentSyncStateSet.add(slaveAddress);
+                markSynchronizingSyncStateSet(currentSyncStateSet);
                 // Notify the upper layer that syncStateSet changed.
                 notifySyncStateSetChanged(currentSyncStateSet);
             }
         }
     }
 
+    private void markSynchronizingSyncStateSet(final Set<String> 
newSyncStateSet) {
+        this.writeLock.lock();
+        try {
+            this.isSynchronizingSyncStateSet = true;
+            this.remoteSyncStateSet.clear();
+            this.remoteSyncStateSet.addAll(newSyncStateSet);
+        } finally {
+            this.writeLock.unlock();
+        }
+    }
+
+    private void markSynchronizingSyncStateSetDone() {
+        this.writeLock.lock();

Review Comment:
   setSyncStateSet已经有lock了,这里不需要再lock



##########
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java:
##########
@@ -258,12 +269,38 @@ public void maybeExpandInSyncStateSet(final String 
slaveAddress, final long slav
             final EpochEntry currentLeaderEpoch = this.epochCache.lastEntry();
             if (slaveMaxOffset >= currentLeaderEpoch.getStartOffset()) {
                 currentSyncStateSet.add(slaveAddress);
+                markSynchronizingSyncStateSet(currentSyncStateSet);
                 // Notify the upper layer that syncStateSet changed.
                 notifySyncStateSetChanged(currentSyncStateSet);
             }
         }
     }
 
+    private void markSynchronizingSyncStateSet(final Set<String> 
newSyncStateSet) {
+        this.writeLock.lock();
+        try {
+            this.isSynchronizingSyncStateSet = true;
+            this.remoteSyncStateSet.clear();
+            this.remoteSyncStateSet.addAll(newSyncStateSet);
+        } finally {
+            this.writeLock.unlock();
+        }
+    }
+
+    private void markSynchronizingSyncStateSetDone() {
+        this.writeLock.lock();
+        try {
+            this.isSynchronizingSyncStateSet = false;
+            this.remoteSyncStateSet.clear();

Review Comment:
   
是否有必要remoteSyncStateSet.clear(),一个是markSynchronizingSyncStateSet执行时会调用remoteSyncStateSet.clear(),另一方面平时remoteSyncStateSet为空也不符合语义



-- 
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