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

[PR] [FLINK-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   ## What is the purpose of the change
   
   Fixed the problem of data loss in window with offset.
   
   ## Brief change log
   
   Passing in window offset when cal nextTriggerWatermark.
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - *Added test that validates that widow data with offset is not lost.*
   
   
   ## 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): no 
     - 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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -194,10 +198,12 @@ public static long getNextTriggerWatermark(
         if (useDayLightSaving) {
             long utcWindowStart =
                     getWindowStartWithOffset(
-                            toUtcTimestampMills(currentWatermark, shiftTimezone), 0L, interval);

Review Comment:
   we should have unit tests for this. 
   I am curious is the watermark time always local - or can it ever be UTC? 



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/tvf/slicing/SliceAssigners.java:
##########
@@ -566,6 +592,11 @@ public long getSliceEndInterval() {
             return innerAssigner.getSliceEndInterval();
         }
 
+        @Override
+        public long getWindowOffset() {
+            return 0;

Review Comment:
   I am curious, if the children do not override this why is the value 0, where everywhere else in the code this getter returns offset.  



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f5816a2c13a4d747c41ecc8680e33b08b36b06be",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "f5816a2c13a4d747c41ecc8680e33b08b36b06be",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f5816a2c13a4d747c41ecc8680e33b08b36b06be 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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   @flinkbot run azure


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/tvf/slicing/SliceAssigners.java:
##########
@@ -566,6 +592,11 @@ public long getSliceEndInterval() {
             return innerAssigner.getSliceEndInterval();
         }
 
+        @Override
+        public long getWindowOffset() {
+            return 0;

Review Comment:
   > If this class is abstract then you don't need to return anything.
   
   Thank you for your reminder. I have change it to "return innerAssigner.getWindowOffset()"



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   @flinkbot  run azure


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   @flinkbot run azure


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -194,10 +198,12 @@ public static long getNextTriggerWatermark(
         if (useDayLightSaving) {
             long utcWindowStart =
                     getWindowStartWithOffset(
-                            toUtcTimestampMills(currentWatermark, shiftTimezone), 0L, interval);

Review Comment:
   we should have unit tests for this with different window offsets and timezones and DLS. 
   I am curious is the watermark time always local - or can it ever be UTC? 
   Is this use of Daylight saving consistent across all watermark processing? 



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -194,10 +198,12 @@ public static long getNextTriggerWatermark(
         if (useDayLightSaving) {
             long utcWindowStart =
                     getWindowStartWithOffset(
-                            toUtcTimestampMills(currentWatermark, shiftTimezone), 0L, interval);

Review Comment:
   we should have unit tests for this with different window offsets and timezones and DLS. 
   I am curious is the watermark time always local - or can it ever be UTC? 



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -194,10 +198,12 @@ public static long getNextTriggerWatermark(
         if (useDayLightSaving) {
             long utcWindowStart =
                     getWindowStartWithOffset(
-                            toUtcTimestampMills(currentWatermark, shiftTimezone), 0L, interval);

Review Comment:
   > timestamp_ltz
   
   Sorry for the ambiguity in my expression. SliceAssigner will save the timezone, and the watermark will be consistent with the timezone. For example, when using timestamp_ltz, the watermark is UTC time. These time conversions are handled in sliceAssigner.



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -194,10 +198,12 @@ public static long getNextTriggerWatermark(
         if (useDayLightSaving) {
             long utcWindowStart =
                     getWindowStartWithOffset(
-                            toUtcTimestampMills(currentWatermark, shiftTimezone), 0L, interval);

Review Comment:
   Is watermark time always local? Does it not depend on whether the watermark field type is Timestamp or timestamp_ltz ?
   https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/timezone/#timestamp-vs-timestamp_ltz
   
   I assume timestamp_ltz would/could have daylight savings, but TIMESTAMP is time from epoch. For time from epoch we should not be adding daylight savings. 



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/tvf/slicing/SliceAssigners.java:
##########
@@ -566,6 +592,11 @@ public long getSliceEndInterval() {
             return innerAssigner.getSliceEndInterval();
         }
 
+        @Override
+        public long getWindowOffset() {
+            return 0;

Review Comment:
   If this class is abstract then you don't need to return anything. 



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   > > Thanks for this contribution! LGTM overall. I just left some comments. BTW, could you please explain a little why the current ITCases do not cover these cases to expose this bug?
   > 
   > Thank you for your comments! I'm sorry, I can't find any harness test that sets the window offset. They all use the default offset=0. Could you give me an example of an existing test that might trigger this bug? And the test data in WindowAggregateITCase is too simple.
   
   What about adding some source data for WindowAggregateITCase#testEventTimeTumbleWindowWithOffset, testCascadeEventTimeTumbleWindowWithOffset, etc to reproduce this bug and to verify this bugfix?


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   @xuyangzhong Dear xuyang, could you please review it for me when you have some time? Thank you!


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -194,10 +198,12 @@ public static long getNextTriggerWatermark(
         if (useDayLightSaving) {
             long utcWindowStart =
                     getWindowStartWithOffset(
-                            toUtcTimestampMills(currentWatermark, shiftTimezone), 0L, interval);

Review Comment:
   UT has tested utc and sh time zones, but lacks offset test. I only added a simple offset test to reproduce the problem.
   watermark time is always local which extract from record.
   I think this use of Daylight saving consistent across all watermark processing, because timerState storage UTC-time and trigger timer need to excute the getNextTriggerWatermark(). I'm not sure about this conclusion, you can double check 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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   @flinkbot run azure


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   @flinkbot run azure


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   Reviewed by Chi on 05/12/24. Asked submitter questions


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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

   > Thanks for this contribution! LGTM overall. I just left some comments. BTW, could you please explain a little why the current ITCases do not cover these cases to expose this bug?
   
   Thank you for your comments! I'm sorry, I can't find any test that sets the window offset. They all use the default offset=0. Could you give me an example of an existing test that might trigger this bug?


-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -184,7 +184,11 @@ public static boolean isWindowFired(
 
     /** Method to get the next watermark to trigger window. */
     public static long getNextTriggerWatermark(

Review Comment:
   Thank you for your suggestion, the modification has been completed.



-- 
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-36664][Window]Window with offset need deal offset when cal nextTriggerWatermark. [flink]

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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/util/TimeWindowUtil.java:
##########
@@ -184,7 +184,11 @@ public static boolean isWindowFired(
 
     /** Method to get the next watermark to trigger window. */
     public static long getNextTriggerWatermark(

Review Comment:
   Could you please add some UT for this method? This will be more clear to check the return results.



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/tvf/slicing/SliceAssigners.java:
##########
@@ -69,6 +69,12 @@ public static TumblingSliceAssigner tumbling(
         return new TumblingSliceAssigner(rowtimeIndex, shiftTimeZone, size.toMillis(), 0);
     }
 
+    public static TumblingSliceAssigner tumbling(

Review Comment:
   Although this simplifies the original `tumbling(...).withOffset(...)`, I think we'd better not introduce new methods if they are only used for testing purposes, as it would slightly increase maintenance, 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