You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/10/28 09:48:00 UTC

[GitHub] [flink] pnowojski commented on a change in pull request #17572: [FLINK-23647][checkpointing] Wait for CheckpointsCleaner to complete before closing cluster

pnowojski commented on a change in pull request #17572:
URL: https://github.com/apache/flink/pull/17572#discussion_r738225093



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointsCleaner.java
##########
@@ -89,9 +95,34 @@ private void cleanup(
                                 checkpoint.getCheckpointID(),
                                 e);
                     } finally {
-                        numberOfCheckpointsToClean.decrementAndGet();
+                        decrementNumberOfCheckpointsToClean();
                         postCleanupAction.run();
                     }
                 });
     }
+
+    private synchronized void decrementNumberOfCheckpointsToClean() {
+        numberOfCheckpointsToClean--;
+        maybeCompleteCloseUnsafe();
+    }
+
+    private void maybeCompleteCloseUnsafe() {
+        if (numberOfCheckpointsToClean == 0 && cleanUpFuture != null) {
+            cleanUpFuture.complete(null);
+        }
+    }
+
+    private synchronized void incrementNumberOfCheckpointsToClean() {
+        checkState(cleanUpFuture == null, "CheckpointsCleaner has already been closed");
+        numberOfCheckpointsToClean++;
+    }
+
+    @Override
+    public synchronized CompletableFuture<Void> closeAsync() {

Review comment:
       After an offline discussion we agreed that keeping `Closeable` is probably slightly better




-- 
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: issues-unsubscribe@flink.apache.org

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