tkalkirill commented on code in PR #6330:
URL: https://github.com/apache/ignite-3/pull/6330#discussion_r2239636603


##########
modules/low-watermark/src/main/java/org/apache/ignite/internal/lowwatermark/LowWatermarkImpl.java:
##########
@@ -212,12 +222,54 @@ public void getLowWatermarkSafe(Consumer<@Nullable 
HybridTimestamp> consumer) {
     }
 
     private void scheduleUpdateLowWatermarkBusy() {
+        scheduleUpdateLowWatermarkTaskLock.lock();
+
+        try {
+            ScheduledUpdateLowWatermarkTask lastTask = 
lastScheduledUpdateLowWatermarkTask.get();
+            ScheduledUpdateLowWatermarkTask newTask = new 
ScheduledUpdateLowWatermarkTask(this, State.NEW);
+
+            State lastTaskState = lastTask == null ? State.COMPLETED : 
lastTask.state();
+
+            switch (lastTaskState) {
+                case NEW:
+                    if (lastTask.tryCancel()) {
+                        boolean casResult = 
lastScheduledUpdateLowWatermarkTask.compareAndSet(lastTask, newTask);
+
+                        assert casResult : "It is forbidden to set a task in 
parallel";
+
+                        scheduleUpdateLowWatermarkTaskBusy(newTask);
+                    }
+
+                    break;
+                case IN_PROGRESS:
+                case CANCELLED:

Review Comment:
   Added a comment, there is no need to process "CANCELLED" in this case, this 
should not be the case, this state is used only for a task that would like to 
start executing.



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to