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

[PR] [FLINK-33702][datastream] Add IncrementalDelayRetryStrategy in AsyncRetryStrategies [flink]

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

   
   
   ## What is the purpose of the change
   
   AsyncRetryStrategies now supports NoRetryStrategy, FixedDelayRetryStrategy and ExponentialBackoffDelayRetryStrategy. In certain scenarios, we also need IncrementalDelayRetryStrategy to reduce the retry count and perform the action more timely. 
   
   
   ## Brief change log
   
     - Add `IncrementalDelayRetryStrategy` in `AsyncRetryStrategies`
     - `IncrementalDelayRetryStrategy` will increase the retry delay at a fixed rate for each attempt
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - Added unit test `AsyncRetryStrategiesTest.testIncrementalDelayRetryStrategy`
   
   ## 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
   


-- 
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-33702][core] Add the IncrementalDelayRetryStrategy implementation of RetryStrategy [flink]

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


##########
flink-core/src/test/java/org/apache/flink/util/concurrent/FixedRetryStrategyTest.java:
##########
@@ -49,6 +49,5 @@ public void testRetryFailure() {
                                 new FixedRetryStrategy(0, Duration.ofMillis(5L))
                                         .getNextRetryStrategy())
                 .isInstanceOf(IllegalStateException.class);
-        ;

Review Comment:
   Good catch!



-- 
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-33702][core] Add the IncrementalDelayRetryStrategy implementation of RetryStrategy [flink]

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


##########
flink-core/src/test/java/org/apache/flink/util/concurrent/FixedRetryStrategyTest.java:
##########
@@ -49,6 +49,5 @@ public void testRetryFailure() {
                                 new FixedRetryStrategy(0, Duration.ofMillis(5L))
                                         .getNextRetryStrategy())
                 .isInstanceOf(IllegalStateException.class);
-        ;

Review Comment:
   This change should belong to the previous hotfix commit.



-- 
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-33702][datastream] Add IncrementalDelayRetryStrategy in AsyncRetryStrategies [flink]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b85ed1529098fbb878ff22eada3c37631ce07749",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b85ed1529098fbb878ff22eada3c37631ce07749",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b85ed1529098fbb878ff22eada3c37631ce07749 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-33702][core] Add the IncrementalDelayRetryStrategy implementation of RetryStrategy [flink]

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


##########
flink-core/src/test/java/org/apache/flink/util/concurrent/IncrementalDelayRetryStrategyTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.util.concurrent;
+
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;

Review Comment:
   junit5 and assertj is required in flink.
   
   `import org.junit.jupiter.api.Test;`
   



##########
flink-core/src/test/java/org/apache/flink/util/concurrent/IncrementalDelayRetryStrategyTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.util.concurrent;
+
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.time.Duration;
+
+import static org.junit.Assert.assertEquals;

Review Comment:
   ```suggestion
   import static org.assertj.core.api.Assertions.assertThat;
   ```



##########
flink-core/src/test/java/org/apache/flink/util/concurrent/IncrementalDelayRetryStrategyTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.util.concurrent;
+
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.time.Duration;
+
+import static org.junit.Assert.assertEquals;
+
+/** Tests for {@link IncrementalDelayRetryStrategy}. */
+public class IncrementalDelayRetryStrategyTest extends TestLogger {
+
+    @Test
+    public void testGettersNotCapped() throws Exception {
+        RetryStrategy retryStrategy =
+                new IncrementalDelayRetryStrategy(
+                        10, Duration.ofMillis(5L), Duration.ofMillis(4L), Duration.ofMillis(20L));
+        assertEquals(10, retryStrategy.getNumRemainingRetries());

Review Comment:
   ```suggestion
           assertThat(retryStrategy.getNumRemainingRetries()).isEqualTo(10);
   ```



##########
flink-core/src/test/java/org/apache/flink/util/concurrent/IncrementalDelayRetryStrategyTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.util.concurrent;
+
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.time.Duration;
+
+import static org.junit.Assert.assertEquals;
+
+/** Tests for {@link IncrementalDelayRetryStrategy}. */
+public class IncrementalDelayRetryStrategyTest extends TestLogger {
+
+    @Test
+    public void testGettersNotCapped() throws Exception {
+        RetryStrategy retryStrategy =
+                new IncrementalDelayRetryStrategy(
+                        10, Duration.ofMillis(5L), Duration.ofMillis(4L), Duration.ofMillis(20L));
+        assertEquals(10, retryStrategy.getNumRemainingRetries());
+        assertEquals(Duration.ofMillis(5L), retryStrategy.getRetryDelay());
+
+        RetryStrategy nextRetryStrategy = retryStrategy.getNextRetryStrategy();
+        assertEquals(9, nextRetryStrategy.getNumRemainingRetries());
+        assertEquals(Duration.ofMillis(9L), nextRetryStrategy.getRetryDelay());
+    }
+
+    @Test
+    public void testGettersHitCapped() throws Exception {
+        RetryStrategy retryStrategy =
+                new IncrementalDelayRetryStrategy(
+                        5, Duration.ofMillis(15L), Duration.ofMillis(10L), Duration.ofMillis(20L));
+        assertEquals(5, retryStrategy.getNumRemainingRetries());
+        assertEquals(Duration.ofMillis(15L), retryStrategy.getRetryDelay());
+
+        RetryStrategy nextRetryStrategy = retryStrategy.getNextRetryStrategy();
+        assertEquals(4, nextRetryStrategy.getNumRemainingRetries());
+        assertEquals(Duration.ofMillis(20L), nextRetryStrategy.getRetryDelay());
+    }
+
+    @Test
+    public void testGettersAtCap() throws Exception {
+        RetryStrategy retryStrategy =
+                new IncrementalDelayRetryStrategy(
+                        5, Duration.ofMillis(20L), Duration.ofMillis(5L), Duration.ofMillis(20L));
+        assertEquals(5, retryStrategy.getNumRemainingRetries());
+        assertEquals(Duration.ofMillis(20L), retryStrategy.getRetryDelay());
+
+        RetryStrategy nextRetryStrategy = retryStrategy.getNextRetryStrategy();
+        assertEquals(4, nextRetryStrategy.getNumRemainingRetries());
+        assertEquals(Duration.ofMillis(20L), nextRetryStrategy.getRetryDelay());
+    }
+
+    /** Tests that getting a next RetryStrategy below zero remaining retries fails. */
+    @Test(expected = IllegalStateException.class)
+    public void testRetryFailure() throws Throwable {
+        new IncrementalDelayRetryStrategy(

Review Comment:
   ```suggestion
           assertThatThrownBy(
                           () -> {
                               new IncrementalDelayRetryStrategy(
                                               0,
                                               Duration.ofMillis(20L),
                                               Duration.ofMillis(5L),
                                               Duration.ofMillis(20L))
                                       .getNextRetryStrategy();
                           })
                   .isInstanceOf(IllegalStateException.class);
   ```



-- 
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-33702][core] Add the IncrementalDelayRetryStrategy implementation of RetryStrategy [flink]

Posted by "huwh (via GitHub)" <gi...@apache.org>.
huwh merged PR #23834:
URL: https://github.com/apache/flink/pull/23834


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