alanwang67 commented on code in PR #4668:
URL: https://github.com/apache/cassandra/pull/4668#discussion_r2990195749


##########
src/java/org/apache/cassandra/tcm/sequences/Move.java:
##########
@@ -203,6 +214,49 @@ public SequenceState executeNext()
                 try
                 {
                     ClusterMetadata metadata = ClusterMetadata.current();
+                    TopologyManager.RegainingEpochRange regainingEpochRange = 
AccordService.instance().topology().epochAndRangeToBeRetired(AccordService.instance().topology().current(),
 AccordTopology.createAccordTopology(applyTo(metadata).success().metadata));
+                    if (regainingEpochRange != null)
+                    {
+                        Condition condition = newOneTimeCondition();
+
+                        class waitForEpochAndRangeRetirement implements 
TopologyListener
+                        {
+                            final Condition condition;
+                            final long waitingForEpoch;
+                            final Ranges waitingForRange;
+
+                            public waitForEpochAndRangeRetirement(Condition 
condition, long waitingForEpoch, Ranges waitingForRange)
+                            {
+                                this.condition = condition;
+                                this.waitingForEpoch = waitingForEpoch;
+                                this.waitingForRange = waitingForRange;
+                            }
+
+                            @Override
+                            public void onEpochRetired(Ranges ranges, long 
epoch, @Nullable Topology topology)
+                            {
+                                try
+                                {
+                                    if (epoch >= waitingForEpoch && 
AccordService.instance().topology().active().get(waitingForEpoch).retired().containsAll(waitingForRange))

Review Comment:
   Think I originally decided to go this way because there is a potential race 
condition between us calculating the exact ranges that need to be retired and 
the registering of the listener. But now that I think about it there is still a 
race condition in the way it's currently being done, except that if another 
range is retired afterwards then it is fine since we consult the global state. 
   
   Not sure if this is the canonical way to do things with listener timing, but 
just added an additional update to get any changes to the ranges that were 
retired that were done in between us calculating it and the registering of the 
listener.



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