Hisoka-X commented on code in PR #6225:
URL: https://github.com/apache/seatunnel/pull/6225#discussion_r1454858419


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointCoordinator.java:
##########
@@ -470,18 +470,24 @@ public static Map<Long, Integer> 
getPipelineTasks(Set<TaskLocation> pipelineSubt
                 .collect(Collectors.toMap(Map.Entry::getKey, entry -> 
entry.getValue().size()));
     }
 
+    @SneakyThrows
     public PassiveCompletableFuture<CompletedCheckpoint> startSavepoint() {
         LOG.info(String.format("Start save point for Job (%s)", jobId));
         if (!isAllTaskReady) {
-            CompletableFuture savepointFuture = new CompletableFuture();
+            CompletableFuture<CompletedCheckpoint> savepointFuture = new 
CompletableFuture<>();
             savepointFuture.completeExceptionally(
                     new CheckpointException(
                             
CheckpointCloseReason.TASK_NOT_ALL_READY_WHEN_SAVEPOINT));
             return new PassiveCompletableFuture<>(savepointFuture);
         }
-        CompletableFuture<PendingCheckpoint> savepoint =
-                createPendingCheckpoint(Instant.now().toEpochMilli(), 
SAVEPOINT_TYPE);
-        startTriggerPendingCheckpoint(savepoint);
+        CompletableFuture<PendingCheckpoint> savepoint;
+        synchronized (lock) {
+            while (pendingCounter.get() > 0) {
+                Thread.sleep(500);
+            }
+            savepoint = createPendingCheckpoint(Instant.now().toEpochMilli(), 
SAVEPOINT_TYPE);
+            startTriggerPendingCheckpoint(savepoint);
+        }

Review Comment:
   Because we should make sure before the savepoint trigger, no other 
checkpoint executed.



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

Reply via email to