pnowojski commented on code in PR #22806:
URL: https://github.com/apache/flink/pull/22806#discussion_r1250876694


##########
flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java:
##########
@@ -220,8 +223,20 @@ void sendEventToSourceOperator(int subtaskId, 
OperatorEvent event) {
                 String.format("Failed to send event %s to subtask %d", event, 
subtaskId));
     }
 
-    ScheduledExecutorService getCoordinatorExecutor() {
-        return coordinatorExecutor;
+    void sendEventToSourceOperatorIfTaskReady(int subtaskId, OperatorEvent 
event) {
+        checkSubtaskIndex(subtaskId);
+
+        callInCoordinatorThread(
+                () -> {
+                    final OperatorCoordinator.SubtaskGateway gateway =
+                            
subtaskGateways.getOnlyGatewayAndNotCheckReady(subtaskId);
+                    if (gateway != null) {
+                        gateway.sendEvent(event);
+                    }

Review Comment:
   I think there might be a race condition. Coordinator might run this check 
successfully and start sending an event, while simultaneously the receiver 
starts restarting? Shouldn't we have a `try/catch` here and actually checking 
if the exception is "retry-able", so things like "subtask has failed" or 
"subtask not ready" or "task is initialising"? 🤔 
   



##########
flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java:
##########
@@ -220,8 +223,20 @@ void sendEventToSourceOperator(int subtaskId, 
OperatorEvent event) {
                 String.format("Failed to send event %s to subtask %d", event, 
subtaskId));
     }
 
-    ScheduledExecutorService getCoordinatorExecutor() {
-        return coordinatorExecutor;
+    void sendEventToSourceOperatorIfTaskReady(int subtaskId, OperatorEvent 
event) {
+        checkSubtaskIndex(subtaskId);
+
+        callInCoordinatorThread(

Review Comment:
   What happens in `callInCoordinatorThread` if there is an unhandled exception 
in the `callable`? Does this failover the job?



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