rpuch commented on code in PR #1384:
URL: https://github.com/apache/ignite-3/pull/1384#discussion_r1034577703


##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/ClusterManagementGroupManager.java:
##########
@@ -466,27 +468,51 @@ private CompletableFuture<CmgRaftService> 
joinCluster(CmgRaftService service, Cl
      * Starts the CMG Raft service using the provided node names as its peers.
      */
     private CompletableFuture<CmgRaftService> 
startCmgRaftService(Collection<String> nodeNames) {
+        String thisNodeConsistentId = 
clusterService.topologyService().localMember().name();
+
+        // If we are not in the CMG, we must be a lerner. List of learners 
will be updated by a leader accordingly,
+        // but just to start a RAFT service we must include ourselves in the 
initial learners list, that's why we
+        // pass List.of(we) as learners list if we are not in the CMG.
+        List<String> learnerConsistentIds = 
nodeNames.contains(thisNodeConsistentId) ? List.of() : 
List.of(thisNodeConsistentId);
+
         try {
             return raftManager
                     .prepareRaftGroup(
                             INSTANCE,
                             nodeNames,
-                            List.of(),
-                            () -> new 
CmgRaftGroupListener(clusterStateStorage, logicalTopologyService),
+                            learnerConsistentIds,
+                            () -> new 
CmgRaftGroupListener(clusterStateStorage, logicalTopology, 
this::onLogicalTopologyChanged),
                             this::createCmgRaftGroupEventsListener,
                             RaftGroupOptions.defaults()
                     )
-                    .thenApply(service -> new CmgRaftService(service, 
clusterService));
+                    .thenApply(service -> new CmgRaftService(service, 
clusterService, logicalTopology));
         } catch (Exception e) {
             return failedFuture(e);
         }
     }
 
+    private void onLogicalTopologyChanged(long term) {
+        CompletableFuture<CmgRaftService> serviceFuture = raftService;

Review Comment:
   Good catch. Added synchronization



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