Skip to content

Commit 3f4474e

Browse files
committed
fix controller mode HAService removeConnection
1 parent 47c6e89 commit 3f4474e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,19 @@ public void shutdown() {
100100
@Override
101101
public void removeConnection(HAConnection conn) {
102102
if (!defaultMessageStore.isShutdown()) {
103-
final Set<Long> syncStateSet = getLocalSyncStateSet();
104103
Long slave = ((AutoSwitchHAConnection) conn).getSlaveId();
105-
if (syncStateSet.contains(slave)) {
106-
syncStateSet.remove(slave);
107-
markSynchronizingSyncStateSet(syncStateSet);
108-
notifySyncStateSetChanged(syncStateSet);
104+
this.writeLock.lock();
105+
try {
106+
final Set<Long> newSyncStateSet = new HashSet<>(this.syncStateSet);
107+
if (newSyncStateSet.contains(slave)) {
108+
newSyncStateSet.remove(slave);
109+
markSynchronizingSyncStateSet(newSyncStateSet);
110+
notifySyncStateSetChanged(newSyncStateSet);
111+
this.syncStateSet.clear();
112+
this.syncStateSet.addAll(newSyncStateSet);
113+
}
114+
} finally {
115+
this.writeLock.unlock();
109116
}
110117
}
111118
super.removeConnection(conn);

0 commit comments

Comments
 (0)