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


##########
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))
+                                        condition.signal();
+                                }
+                                catch (TopologyRetiredException e)
+                                {
+                                    condition.signal();
+                                }
+                                catch (TopologyException e)
+                                {
+                                    logger.info("Topology exception: ", e);
+                                }
+                            }
+                        }
+
+                        waitForEpochAndRangeRetirement wait = new 
waitForEpochAndRangeRetirement(condition, regainingEpochRange.epoch(), 
regainingEpochRange.range());
+                        AccordService.instance().topology().addListener(wait);
+                        condition.awaitThrowUncheckedOnInterrupt();
+                        
AccordService.instance().topology().removeListener(wait);

Review Comment:
   Do you mean just the `removeListener`? Since if we put the whole code block 
in a `finally` then we don't wait for the ranges to be retired prior to TCM 
committing the start move. 



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