You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "dchristle (via GitHub)" <gi...@apache.org> on 2024/01/29 02:15:17 UTC

[PR] [FLINK-34252] [table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

dchristle opened a new pull request, #24211:
URL: https://github.com/apache/flink/pull/24211

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   In the current implementation, the lastRecordTime variable, which tracks the time of the last received data element, is updated only when the WatermarkStatus transitions from IDLE to ACTIVE. However, it is not updated when WatermarkStatus is ACTIVE, which means even under continuous data flow, the condition `(currentTime - lastRecordTime > idleTimeout)` will eventually always become true, and the WatermarkStatus will erroneously be marked IDLE.
   
   It is unclear to me if this bug produces any incorrectness downstream, since when the WatermarkStatus is in in the IDLE state, the next processElement will cause a WatermarkStatus.ACTIVE to be emitted. Nevertheless, we should eliminate this flip-flop behavior between states.
   
   ## Brief change log
   
    - Update lastRecordTime in table WatermarkAssignerOperator on each record to prevent idle WatermarkStatus
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - Added test that validates the WatermarkStatus is not set to idle when records are sent more frequently than the idleTimeout
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (yes)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on PR #24211:
URL: https://github.com/apache/flink/pull/24211#issuecomment-1960948515

   > 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.
   
   Yes, that's a valid combination with idleness in at least a couple of cases:
   - watermark is emitted in `onEvent`, for example for every record OR if there is already some special record in the source that represents a watermark
   - given `Source`/`SourceReader` handles emission of watermarks on it's own, but doesn't handle idleness
   In both cases `watermarkInterval = 0` and `idleTimeout > 0` could be a desired configuration.
   
   > 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 & we'd never try to detect idleness.
   
   That's a good catch @dchristle!
   
   This safety net for an overloaded subtask thread I think might no longer be needed. In the past the timer thread trying to emit periodic watermark and the subtask/source thread would try to compete to acquire the same lock. AFAIK the original authors were worried about lock starvation (I'm not even sure if this was really needed, as AFAIK kernels do not guarantee fairness, but guarantee that threads won't be starved on locks acquisition). Currently the synchronisation mechanism is very different, and I would say there is no real need for this extra code path.
   
   So if it makes things simpler I would be fine removing this safety net.


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski closed pull request #24211: [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator 
URL: https://github.com/apache/flink/pull/24211


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "dchristle (via GitHub)" <gi...@apache.org>.
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/user@flink.apache.org/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 & we'd 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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #24211:
URL: https://github.com/apache/flink/pull/24211#issuecomment-1913851473

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "3b898a0c74a5dcb957ab7ab30b79dd82d01e8c0e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "3b898a0c74a5dcb957ab7ab30b79dd82d01e8c0e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 3b898a0c74a5dcb957ab7ab30b79dd82d01e8c0e UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1495910626


##########
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:
   > Does idleTimeout < watermarkInterval have any sense? Shouldn't this be disallowed even? But if you have doubts, we can support that case here.
   
   Sorry, I mean we didn't forbid it, so we cannot assume it.
   
   From your comment, I think we can limit `idleTimeout > watermarkInterval`.



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1495762047


##########
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:
   > A workaround solution is we only register a timer with min(idleTimeout, watermarkInterval) latency.
   
   Does `idleTimeout < watermarkInterval` have any sense? Shouldn't this be disallowed even? But if you have doubts, we can support that case here.
   
   Given that when timer is registered for value `<> watermarkInterval`, and in that case we need some special handling in the timer callback, whether it's time to emit watermark or not, maybe it makes more sense to calculate some more fancy timer interval? For example:
   ```
   if min(watermarkInterval, idleTimeout) * 5  < max(watermarkInterval, idleTimeout)
     return min(watermarkInterval, idleTimeout)
   else 
     return max(min(watermarkInterval, idleTimeout)/5, 1)
   ```
   That would ensure our accuracy is roughly speaking always good enough? And the code in the callback to determine whether it's time to check idleness and/or emit watermark would basically remain the same.
   
   > We can register a timer with idleTimeout latency.
   
   Yes, that's what I had in mind :) 



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1495341757


##########
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 for this valuable comment!
   
   > We can not call getProcessingTimeService().getCurrentProcessingTime() per every record, that's a too costly operation.
   
   Good catch, I didn't notice it before.
   
   > I think we could use a trick to count emitted records here, in the processElement. Then in WatermarkAssignerOperator#onProcessingTime you could periodically check if the processed elements count has changed and update lastRecordTime there if it did. That would loose us a little bit of accuracy, but not much. For example if processing timer is triggered ~5x more frequently than idleTimeout, the average accuracy lost would be only ~10%, which is negligible.
   
   The solution make sense to me.
   
   > If both idleTimeout > 0 && watermarkInterval > 0, we might need to somehow handle two timers frequencies:
   > I guess we could register two different ProcessingTimeCallback with two different frequencies.
   > Or we can ignore the problem and if both idleTimeout > 0 && watermarkInterval > 0, we could just have a single timer with watermarkInterval latency. This option is probably simpler, and might be good enough as usually (almost always?) watermarkInterval << idleTimeout.
   
   In general, `watermarkInterval << idleTimeout`, but it isn't always right. Users can set them randomly, we cannot ensure how user set them. 
   
   A workaround solution is we only register a timer with `min(idleTimeout, watermarkInterval)` latency.
   
   
   > For `watermarkInterval == 0 && idleTimeout > 0`.
   
   We can register a timer with `idleTimeout` latency.
   
   WDYT?



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1494192141


##########
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:
   We can not call `getProcessingTimeService().getCurrentProcessingTime()` per every record, that's a too costly operation.
   
   I think we could use a trick to count emitted records here, in the `processElement`. Then in `WatermarkAssignerOperator#onProcessingTime` you could periodically check if the processed elements count has changed and update `lastRecordTime` there if it did. That would loose us a little bit of accuracy, but not much. For example if processing timer is triggered ~5x more frequently than `idleTimeout`, the average accuracy lost would be only ~10%, which is negligible.
   
   A couple of extra complications that I see are:
   - This operator registers a processing time timer only if periodic watermarks are enabled (`watermarkInterval > 0`). The code would have to be adapted to register and fire timers also if `watermarkInterval == 0 && idleTimeout > 0`.
   - If both `idleTimeout > 0 && watermarkInterval > 0`, we might need to somehow handle two timers frequencies:
     - I guess we could register two different `ProcessingTimeCallback` with two different frequencies.
     - Or we can ignore the problem and if both `idleTimeout > 0 && watermarkInterval > 0`, we could just have a single timer with `watermarkInterval` latency. This option is probably simpler, and might be good enough as usually (almost always?) `watermarkInterval << idleTimeout`.
   
   Or have I missed something?



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on PR #24211:
URL: https://github.com/apache/flink/pull/24211#issuecomment-2168078012

   I've prepared an improved version of this PR: https://github.com/apache/flink/pull/24941
   
   Closing this in favour the newer one.


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "dchristle (via GitHub)" <gi...@apache.org>.
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/user@flink.apache.org/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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-34252][table] Fix lastRecordTime tracking in WatermarkAssignerOperator [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #24211:
URL: https://github.com/apache/flink/pull/24211#discussion_r1495762047


##########
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:
   > A workaround solution is we only register a timer with min(idleTimeout, watermarkInterval) latency.
   
   Does `idleTimeout < watermarkInterval` have any sense? Shouldn't this be disallowed even? But if you have doubts, we can support that case here.
   
   Given that when timer is registered for value `<> watermarkInterval`, and in that case we need some special handling in the timer callback, whether it's time to emit watermark or not, maybe it makes more sense to calculate some more fancy timer interval? For example:
   ```
   if min(watermarkInterval, idleTimeout) * 5  < max(watermarkInterval, idleTimeout)
     return min(watermarkInterval, idleTimeout)
   else 
     return max(min(watermarkInterval, idleTimeout)/5, 1)
   ```
   That would ensure our accuracy is roughly speaking always good enough?
   
   > We can register a timer with idleTimeout latency.
   
   Yes, that's what I had in mind :) 



-- 
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: issues-unsubscribe@flink.apache.org

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