You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "pnowojski (via GitHub)" <gi...@apache.org> on 2023/03/14 13:55:02 UTC

[GitHub] [flink] pnowojski commented on a diff in pull request #22168: [FLINK-31414][checkpointing] exceptions in the alignment timer are ig…

pnowojski commented on code in PR #22168:
URL: https://github.com/apache/flink/pull/22168#discussion_r1135584436


##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/io/checkpointing/BarrierAlignmentUtilTest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.io.checkpointing;
+
+import org.apache.flink.api.common.operators.MailboxExecutor;
+import org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor;
+import org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService;
+import org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl;
+import org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailbox;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailboxImpl;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.time.Duration;
+
+import static org.junit.Assert.assertThrows;
+
+public class BarrierAlignmentUtilTest {
+
+    @Test
+    public void testDelayableTimerNotHiddenException() throws Exception {
+        TaskMailbox mailbox = new TaskMailboxImpl();
+        MailboxProcessor mailboxProcessor =
+                new MailboxProcessor(controller -> {}, mailbox, StreamTaskActionExecutor.IMMEDIATE);
+        MailboxExecutor mailboxExecutor =
+                new MailboxExecutorImpl(
+                        mailbox, 0, StreamTaskActionExecutor.IMMEDIATE, mailboxProcessor);
+
+        TestProcessingTimeService timerService = new TestProcessingTimeService();
+        timerService.setCurrentTime(System.currentTimeMillis());
+
+        BarrierAlignmentUtil.DelayableTimer delayableTimer =
+                BarrierAlignmentUtil.createRegisterTimerCallback(mailboxExecutor, timerService);
+
+        Duration delay = Duration.ofMinutes(10);
+
+        delayableTimer.registerTask(
+                () -> {
+                    // simulate IOException in checkpoint sync phase
+                    throw new IOException();
+                },
+                delay);
+
+        timerService.advance(delay.toMillis());
+
+        assertThrows(
+                "BarrierAlignmentUtil.DelayableTimer should not hidden exception",
+                IOException.class,
+                () -> mailboxProcessor.runMailboxStep());

Review Comment:
   nit: If you use `org.apache.flink.util.ExceptionUtils#assertThrowable(...)` or `ExceptionUtils#findThrowable` the test would be more resilient (for example if the original exception will be wrapped on some layer.



##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/io/checkpointing/BarrierAlignmentUtilTest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.io.checkpointing;
+
+import org.apache.flink.api.common.operators.MailboxExecutor;
+import org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor;
+import org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService;
+import org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl;
+import org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailbox;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailboxImpl;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.time.Duration;
+
+import static org.junit.Assert.assertThrows;
+
+public class BarrierAlignmentUtilTest {
+
+    @Test
+    public void testDelayableTimerNotHiddenException() throws Exception {
+        TaskMailbox mailbox = new TaskMailboxImpl();
+        MailboxProcessor mailboxProcessor =
+                new MailboxProcessor(controller -> {}, mailbox, StreamTaskActionExecutor.IMMEDIATE);
+        MailboxExecutor mailboxExecutor =
+                new MailboxExecutorImpl(
+                        mailbox, 0, StreamTaskActionExecutor.IMMEDIATE, mailboxProcessor);
+
+        TestProcessingTimeService timerService = new TestProcessingTimeService();
+        timerService.setCurrentTime(System.currentTimeMillis());
+
+        BarrierAlignmentUtil.DelayableTimer delayableTimer =
+                BarrierAlignmentUtil.createRegisterTimerCallback(mailboxExecutor, timerService);
+
+        Duration delay = Duration.ofMinutes(10);
+
+        delayableTimer.registerTask(
+                () -> {
+                    // simulate IOException in checkpoint sync phase
+                    throw new IOException();

Review Comment:
   nit: I would throw a custom exception, like for example `org.apache.flink.runtime.operators.testutils.ExpectedTestException`. It's less likely to collide with some actual failure reported via `IOException`.



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