dchristle commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1499603545


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/wmassigners/WatermarkAssignerOperator.java:
##########
@@ -100,11 +100,14 @@ public void open() throws Exception {
 
     @Override
     public void processElement(StreamRecord<RowData> element) throws Exception 
{
-        if (idleTimeout > 0 && currentStatus.equals(WatermarkStatus.IDLE)) {
-            // mark the channel active
-            emitWatermarkStatus(WatermarkStatus.ACTIVE);
+        if (idleTimeout > 0) {
+            if (currentStatus.equals(WatermarkStatus.IDLE)) {
+                // mark the channel active
+                emitWatermarkStatus(WatermarkStatus.ACTIVE);
+            }
             lastRecordTime = 
getProcessingTimeService().getCurrentProcessingTime();
         }

Review Comment:
   Thanks @pnowojski and @1996fanrui for the review. The approach to avoid 
`getProcessingTimeService().getCurrentProcessingTime()` each record seems sound 
to me and should be straightforward to implement.
   
   > For watermarkInterval == 0 && idleTimeout > 0
   
   Do we know if `watermarkInterval == 0` is a valid case where we are sure we 
need to periodically emit `WatermarkStatus`? My interpretation when first 
reading this code was that a zero value is a sentinel indicating the user isn't 
using watermarks. If that's the case, does the concept of "idleness" make sense 
anymore? Perhaps we don't emit anything for `watermarkInterval == 0`.
   
   A [mailing list 
thread](https://www.mail-archive.com/[email protected]/msg40520.html) 
discusses some confusion in the docs on the meaning of an auto-watermark 
interval set to zero -- whether it means emitting a watermark each record, or 
not emitting them at all. 
   
   A reply by @wuchong writes that the zero value:
   > just disable **periodic** watermark emission, it doesn't mean the 
watermark will never be emitted.
   
   So, there may be watermarks from elsewhere when `watermarkInterval == 0`. 
But does that mean we need to support idleness detection here?
   
   The current code _would_ work in the case of a zero watermark interval, but 
only because of the last part of `processElement` where `advanceWatermark()` is 
called. That code is commented with:
   > // eagerly emit watermark to avoid period timer not called (this often 
happens when cpu load is high)
   
   It seems like the intent was to ensure advancement under high load, rather 
than support the `watermarkInterval == 0` case. Without this eager advancement, 
the code would never emit `Watermark`, since no timers would be scheduled & 
never try to detect idleness.



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