flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] dawidwys commented on a change in pull request #15241: [FLINK-5717][datastream] Fix NPE and lost timer during window merging for ContinuousProcessingTimeTrigger
Date Wed, 24 Mar 2021 14:50:55 GMT

dawidwys commented on a change in pull request #15241:
URL: https://github.com/apache/flink/pull/15241#discussion_r600542073



##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/triggers/ContinuousProcessingTimeTrigger.java
##########
@@ -99,8 +102,15 @@ public boolean canMerge() {
     }
 
     @Override
-    public void onMerge(W window, OnMergeContext ctx) {
+    public void onMerge(W window, OnMergeContext ctx) throws Exception {
+        // States for old windows will lost after.

Review comment:
       ```suggestion
           // States for old windows will be lost after the call.
   ```

##########
File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/windowing/ContinuousProcessingTimeTriggerTest.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.runtime.operators.windowing;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.streaming.api.windowing.time.Time;
+import org.apache.flink.streaming.api.windowing.triggers.ContinuousProcessingTimeTrigger;
+import org.apache.flink.streaming.api.windowing.triggers.TriggerResult;
+import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+
+import org.apache.flink.shaded.guava18.com.google.common.collect.Lists;
+
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link ContinuousProcessingTimeTrigger}. */
+public class ContinuousProcessingTimeTriggerTest {
+    @Test
+    public void testMergingWindows() throws Exception {

Review comment:
       Could we use `KeyedOneInputStreamOperatorTestHarness` instead of modifying the `TriggerTestHarness`?
   You should be able to advance processing time via: `testHarness.getProcessingTimeService().setCurrentTime()`.
   
   TBH, I'd feel safer if we do not need to modify the `TriggerTestHarness`.

##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/WindowOperator.java
##########
@@ -466,9 +466,12 @@ public void onEventTime(InternalTimer<K, W> timer) throws Exception
{
             mergingWindows = getMergingWindowSet();
             W stateWindow = mergingWindows.getStateWindow(triggerContext.window);
             if (stateWindow == null) {
-                // Timer firing for non-existent window, this can only happen if a
-                // trigger did not clean up timers. We have already cleared the merging
-                // window and therefore the Trigger state, however, so nothing to do.
+                // Timer firing for non-existent window, this can happen:

Review comment:
       I actually find the old comment good enough and easier to understand than the updated
version.




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

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



Mime
View raw message