dcapwell commented on code in PR #3416:
URL: https://github.com/apache/cassandra/pull/3416#discussion_r1777750111


##########
src/java/org/apache/cassandra/service/accord/AccordConfigurationService.java:
##########
@@ -293,27 +303,54 @@ synchronized void updateMapping(ClusterMetadata metadata)
 
     private void reportMetadata(ClusterMetadata metadata)
     {
-        Stage.MISC.submit(() -> {
-            synchronized (AccordConfigurationService.this)
+        Stage.MISC.submit(() -> reportMetadataInternal(metadata));
+    }
+
+    synchronized void reportMetadataInternal(ClusterMetadata metadata)
+    {
+        updateMapping(metadata);
+        Topology topology = AccordTopology.createAccordTopology(metadata);
+        if (Invariants.isParanoid())
+        {
+            for (Node.Id node : topology.nodes())
             {
-                updateMapping(metadata);
-                Topology topology = 
AccordTopology.createAccordTopology(metadata);
-                Topology current = isEmpty() ? Topology.EMPTY : 
currentTopology();
-                reportTopology(topology);
-                Sets.SetView<Node.Id> removedNodes = 
Sets.difference(current.nodes(), topology.nodes());
-                if (!removedNodes.isEmpty())
-                    onNodesRemoved(topology.epoch(), removedNodes);
+                if (mapping.mappedEndpointOrNull(node) == null)
+                    throw new IllegalStateException("Epoch " + 
topology.epoch() + " has node " + node + " but mapping does not!");
             }
-        });
+        }
+        Topology current = isEmpty() ? Topology.EMPTY : currentTopology();
+        reportTopology(topology);
+        // for all nodes removed, or pending removal, mark them as removed so 
we don't wait on their replies
+        Sets.SetView<Node.Id> removedNodes = Sets.difference(current.nodes(), 
topology.nodes());
+        if (!removedNodes.isEmpty())
+        {
+            onNodesRemoved(topology.epoch(), removedNodes);
+            for (Node.Id node : removedNodes)
+            {
+                if (shareShard(current, node, localId))
+                    AccordService.instance().tryMarkRemoved(current, node);
+            }
+        }
+    }
+
+    private static boolean shareShard(Topology current, Node.Id target, 
Node.Id self)
+    {
+        for (Shard shard : current.shards())
+        {
+            if (!shard.contains(target)) continue;
+            if (shard.contains(self)) return true;
+        }
+        return false;
     }
 
-    private synchronized void onNodesRemoved(long epoch, Set<Node.Id> removed)
+    public synchronized void onNodesRemoved(long epoch, Set<Node.Id> removed)
     {
+        if (removed.isEmpty()) return;
         syncPropagator.onNodesRemoved(removed);
         for (long oldEpoch : nonCompletedEpochsBefore(epoch))
         {
             for (Node.Id node : removed)
-                receiveRemoteSyncComplete(node, oldEpoch);
+                receiveRemoteSyncCompletePreListenerNotify(node, oldEpoch);

Review Comment:
   doing remote sync complete would double count as `onRemoveNodes` would also 
ack for the node... we need this to update disk state



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to