You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2023/01/12 11:19:26 UTC

[GitHub] [rocketmq] hzh0425 commented on a diff in pull request #5798: [ISSUE #5663] Fix Messages may be lost when SyncStateSet expand in extreme scenarios

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


##########
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:
   Good idea



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org