alievmirza commented on code in PR #7539:
URL: https://github.com/apache/ignite-3/pull/7539#discussion_r2772859714


##########
modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java:
##########
@@ -145,25 +152,30 @@ private TopologyAwareRaftGroupService(
             public void onNodeJoined(LogicalNode appearedNode, 
LogicalTopologySnapshot newTopology) {
                 Peer peer = new Peer(appearedNode.name(), 0);
 
-                if (peers().contains(peer)) {
-                    if (serverEventHandler.isSubscribed() && 
appearedNode.name().equals(peer.consistentId())) {
-                        LOG.info("New peer will be sending a leader elected 
notification [grpId={}, consistentId={}]", groupId(),
-                                peer.consistentId());
-
-                        subscribeToNode(appearedNode, 
peer).thenComposeAsync(subscribed -> {
-                            if (subscribed) {
-                                return refreshAndGetLeaderWithTerm()
-                                        .thenAcceptAsync(leaderWithTerm -> {
-                                            if (!leaderWithTerm.isEmpty()
-                                                    && 
appearedNode.name().equals(leaderWithTerm.leader().consistentId())) {
-                                                
serverEventHandler.onLeaderElected(appearedNode, leaderWithTerm.term());
-                                            }
-                                        }, executor);
-                            }
-
-                            return nullCompletedFuture();
-                        }, executor);
-                    }
+                if (peers().contains(peer) && 
serverEventHandler.isSubscribed()) {
+                    LOG.info("New peer will be sending a leader elected 
notification [grpId={}, consistentId={}]", groupId(),
+                            peer.consistentId());
+
+                    AtomicBoolean leftWhileSubscribing = new 
AtomicBoolean(false);
+                    nodeLeftLtDuringSubscriptionMarkers.put(appearedNode.id(), 
leftWhileSubscribing);
+
+                    subscribeToNode(appearedNode, peer, leftWhileSubscribing)
+                            .thenComposeAsync(subscribed -> {
+                                if (subscribed) {

Review Comment:
   Shouldn't we set false to `leftWhileSubscribing` in map for some cases when 
`subscribed == false`? For example this code in `sendWithRetry` could be 
interpreted as `left while subscribing`, couldn't it?  
   
   ```
                   } else {
                       LOG.debug("An exception while trying to unsubscribe", 
invokeThrowable);
   
                       msgSendFut.complete(false);
                   }
   ```



##########
modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java:
##########
@@ -172,6 +184,11 @@ public void onNodeLeft(LogicalNode leftNode, 
LogicalTopologySnapshot newTopology
                 Peer peerToRemove = new Peer(leftNode.name(), 0);
 
                 subscribersMap.remove(peerToRemove);
+
+                AtomicBoolean leftMarker = 
nodeLeftLtDuringSubscriptionMarkers.remove(leftNode.id());

Review Comment:
   It seems to me that if CMG majority is lost we still could be in infinite 
loop, because we do not receive on node left event



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