MartijnVisser commented on code in PR #29445:
URL: https://github.com/apache/flink/pull/29445#discussion_r4621056082


##########
flink-state-backends/flink-statebackend-common/src/main/java/org/apache/flink/state/common/PeriodicMaterializationManager.java:
##########
@@ -205,12 +205,26 @@ public void start() {
     }
 
     // task thread and task canceler can access this method
-    public synchronized void close() {
+    public void close() {
 
         LOG.info("Shutting down PeriodicMaterializationManager.");
 
-        if (!periodicExecutor.isShutdown()) {
-            periodicExecutor.shutdownNow();
+        synchronized (this) {
+            if (!periodicExecutor.isShutdown()) {
+                periodicExecutor.shutdownNow();
+            }
+        }
+
+        // A running callback may need the manager lock to schedule its next 
materialization.

Review Comment:
   With the test commits, no test in the module keeps a started manager open 
past its first delay (17.1 s at the shortest), so the overlap this guards 
against does not occur.



##########
flink-state-backends/flink-statebackend-common/src/main/java/org/apache/flink/state/common/PeriodicMaterializationManager.java:
##########
@@ -205,12 +205,26 @@ public void start() {
     }
 
     // task thread and task canceler can access this method
-    public synchronized void close() {
+    public void close() {
 
         LOG.info("Shutting down PeriodicMaterializationManager.");
 
-        if (!periodicExecutor.isShutdown()) {
-            periodicExecutor.shutdownNow();
+        synchronized (this) {
+            if (!periodicExecutor.isShutdown()) {
+                periodicExecutor.shutdownNow();
+            }
+        }
+
+        // A running callback may need the manager lock to schedule its next 
materialization.
+        try {
+            if (!periodicExecutor.awaitTermination(5, TimeUnit.SECONDS)) {

Review Comment:
   In a fork held past 254.6 s, `ChangelogStateBackendMigrationTest` still 
crashes 3 of 3 runs with only this commit, and 0 of 3 with only the two test 
commits. I think we can drop it.



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