ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] Jokser commented on a change in pull request #5765: IGNITE-10078 Node failure during concurrent partition updates may cause partition desync between primary and backup.
Date Tue, 14 May 2019 13:17:57 GMT
Jokser commented on a change in pull request #5765: IGNITE-10078 Node failure during concurrent
partition updates may cause partition desync between primary and backup.
URL: https://github.com/apache/ignite/pull/5765#discussion_r283720020
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
 ##########
 @@ -2466,79 +2485,61 @@ private void initAffinityOnNodeJoin(
         assert affTopVer.topologyVersion() > 0 : "Affinity is not initialized [grp=" +
aff.cacheOrGroupName() +
             ", topVer=" + affTopVer + ", node=" + cctx.localNodeId() + ']';
 
-        assert aff.idealAssignmentRaw() != null : "Previous assignment is not available.";
+        List<List<ClusterNode>> curAff = aff.assignments(affTopVer);
+
+        assert aff.idealAssignment() != null : "Previous assignment is not available.";
 
-        IdealAffinityAssignment idealAssignment = aff.calculate(evts.topologyVersion(), evts,
evts.discoveryCache());
-        List<List<ClusterNode>> curAssignment = aff.assignments(affTopVer);
+        List<List<ClusterNode>> idealAssignment = aff.calculate(evts.topologyVersion(),
evts, evts.discoveryCache()).assignment();
         List<List<ClusterNode>> newAssignment = null;
 
         if (latePrimary) {
-            BitSet processedPartitions = new BitSet(curAssignment.size());
+            for (int p = 0; p < idealAssignment.size(); p++) {
+                List<ClusterNode> newNodes = idealAssignment.get(p);
+                List<ClusterNode> curNodes = curAff.get(p);
 
-            // Late affinity assignment to changed primaries.
-            for (ClusterNode joinedNode : evts.joinedServerNodes()) {
-                Set<Integer> primaries = idealAssignment.idealPrimaries(joinedNode);
-
-                for (int p : primaries) {
-                    List<ClusterNode> curNodes = curAssignment.get(p);
-
-                    if (curNodes.isEmpty())
-                        continue;
-
-                    ClusterNode curPrimary = curNodes.get(0);
+                ClusterNode curPrimary = !curNodes.isEmpty() ? curNodes.get(0) : null;
+                ClusterNode newPrimary = !newNodes.isEmpty() ? newNodes.get(0) : null;
 
+                if (curPrimary != null && newPrimary != null && !curPrimary.equals(newPrimary))
{
                     assert cctx.discovery().node(evts.topologyVersion(), curPrimary.id())
!= null : curPrimary;
 
-                    List<ClusterNode> idealNodes = idealAssignment.assignment().get(p);
-
-                    List<ClusterNode> newNodes = latePrimaryAssignment(aff,
+                    List<ClusterNode> nodes0 = latePrimaryAssignment(aff,
                         p,
                         curPrimary,
-                        idealNodes,
+                        newNodes,
                         rebalanceInfo);
 
                     if (newAssignment == null)
-                        newAssignment = new ArrayList<>(idealAssignment.assignment());
+                        newAssignment = new ArrayList<>(idealAssignment);
 
-                    newAssignment.set(p, newNodes);
-
-                    processedPartitions.set(p);
+                    newAssignment.set(p, nodes0);
                 }
             }
+        }
 
-            Set<Integer> partitionsWithChangedPrimary = aff.partitionPrimariesDifferentToIdeal(affTopVer);
-
-            for (int p : partitionsWithChangedPrimary) {
-                // Already processed above.
-                if (processedPartitions.get(p))
-                    continue;
-
-                List<ClusterNode> curNodes = curAssignment.get(p);
-
-                if (curNodes.isEmpty())
-                    continue;
-
-                List<ClusterNode> idealOwners = idealAssignment.assignment().get(p);
-
-                if (!curNodes.get(0).equals(idealOwners.get(0))) {
-                    List<ClusterNode> newNodes = latePrimaryAssignment(aff,
-                        p,
-                        curNodes.get(0),
-                        idealOwners,
-                        rebalanceInfo);
+        if (newAssignment == null)
+            newAssignment = idealAssignment;
 
-                    if (newAssignment == null)
-                        newAssignment = new ArrayList<>(idealAssignment.assignment());
+        aff.initialize(evts.topologyVersion(), cachedAssignment(aff, newAssignment, affCache));
+    }
 
-                    newAssignment.set(p, newNodes);
-                }
-            }
-        }
+    /**
+     * @param aff Assignment cache.
+     * @param assign Assignment.
+     * @param affCache Assignments already calculated for other caches.
+     * @return Assignment.
+     */
+    private List<List<ClusterNode>> cachedAssignment(GridAffinityAssignmentCache
aff,
 
 Review comment:
   Cached assignment functionality can be removed because it's not properly working when affinity
calculating in parallel.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message