1996fanrui commented on code in PR #29954:
URL: https://github.com/apache/flink/pull/29954#discussion_r4682664248


##########
flink-runtime/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java:
##########
@@ -1888,7 +1894,18 @@ private void tryShutdownTimerService(long timeoutMs, 
TimerService timerService)
     public void dispatchOperatorEvent(OperatorID operator, 
SerializedValue<OperatorEvent> event)
             throws FlinkException {
         try {
+            // Operator events must be urgent: the coordinator considers an 
event delivered once it
+            // is enqueued here, and it may then take a checkpoint that must 
include the event's
+            // effect (e.g. AddSplitEvent). Unaligned checkpoint triggers are 
urgent mails (see
+            // triggerCheckpointAsync), so a normal mail could be overtaken by 
the trigger. Urgent
+            // mails are executed in FIFO order among themselves 
(TaskMailboxImpl keeps them in a
+            // dedicated FIFO urgent queue served before the batch; both mails 
are put with the
+            // same priority), which preserves the ordering.
+            // This is also safe for an aligned trigger (a normal mail): the 
coordinator's gateway
+            // stays closed from its checkpoint until the task's 
AcknowledgeCheckpointEvent, which
+            // is sent after the task-side snapshot, so later events can't 
overtake the snapshot.
             mainMailboxExecutor.execute(
+                    MailboxExecutor.MailOptions.urgent(),
                     () -> operatorChain.dispatchOperatorEvent(operator, event),

Review Comment:
   Making every `OperatorEvent` urgent looks risky to me.
   - The bug was only that the UC trigger overtook a queued `AddSplitEvent`.
   - But now all events, including custom ones from connectors, overtake all 
normal mails (timers, `notifyCheckpointComplete`, ...).
   - Fine for today's events, but future events may rely on the old FIFO order.
   
   Is this intended? If so, could we document 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