rkhachatryan commented on a change in pull request #14968:
URL: https://github.com/apache/flink/pull/14968#discussion_r579453364



##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/SourceStreamTaskTest.java
##########
@@ -856,4 +887,41 @@ private void output(String record) {
             output.collect(new StreamRecord<>(record));
         }
     }
+
+    /**
+     * This source sleeps a little bit before processing cancellation and 
records whether it was
+     * interrupted by the {@link SourceStreamTask} or not.
+     */
+    private static class WasInterruptedTestingSource implements 
SourceFunction<String> {
+        private static final int MAX_POST_CANCEL_ITERATIONS = 100;
+        private static final long serialVersionUID = 1L;
+        private volatile boolean running;
+
+        public static boolean wasInterrupted;
+
+        @Override
+        public void run(SourceContext<String> ctx) throws Exception {
+            wasInterrupted = false;
+            try {
+                int postCancelIterations = 0;
+                while (running || postCancelIterations < 
MAX_POST_CANCEL_ITERATIONS) {

Review comment:
       I think it's better to signal explicitly that this thread can exit 
(after `notifyCheckpointCompleteAsync`?).
   Otherwise, if there is a pause between `cancel` call and (errouneous) 
`interrupt` that interrupt can go unnoticed.
   
   I reverted the fix and added 1s pause in `SourceStreamTask` - and the test 
passed (with running=true)




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

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


Reply via email to