You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/10/18 15:50:56 UTC

[GitHub] [flink] elphastori opened a new pull request, #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

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

   <!--
   *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
   
   *(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
   
   
   ## Brief change log
   
   *(for example:)*
     - *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
     - *Deployments RPC transmits only the blob storage reference*
     - *TaskManagers retrieve the TaskInfo from the blob cache*
   
   
   ## Verifying this change
   
   Please make sure both new and modified tests in this PR follows the conventions defined in our code quality guide: https://flink.apache.org/contributing/code-style-and-quality-common.html#testing
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (100MB)*
     - *Extended integration test for recovery after master (JobManager) failure*
     - *Added test that validates that TaskInfo is transferred only once across recoveries*
     - *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


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


[GitHub] [flink] flinkbot commented on pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21102:
URL: https://github.com/apache/flink/pull/21102#issuecomment-1282632194

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3e98e33fab4e00b607fda3cfd7cd3e9b612ddb6",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "c3e98e33fab4e00b607fda3cfd7cd3e9b612ddb6",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c3e98e33fab4e00b607fda3cfd7cd3e9b612ddb6 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


[GitHub] [flink] dannycranmer commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1009647157


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxyTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import org.apache.flink.streaming.connectors.kinesis.model.StreamShardHandle;
+
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.model.GetShardIteratorRequest;
+import com.amazonaws.services.kinesis.model.GetShardIteratorResult;
+import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
+import com.amazonaws.services.kinesis.model.Shard;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
+/** Test for methods in the {@link DynamoDBStreamsProxy} class. */
+public class DynamoDBStreamsProxyTest {
+
+    @Test
+    public void testGetShardIterator() throws Exception {
+        // given
+        String fakeStreamName = "fake-stream";
+
+        List<String> shardIds =
+                Arrays.asList(
+                        "shardId-000000000000",
+                        "shardId-000000000001",
+                        "shardId-000000000002",
+                        "shardId-000000000003");
+
+        String invalidShardId = "shardId-000000000004";
+
+        AmazonKinesis mockClient = mock(AmazonKinesis.class);

Review Comment:
   We are [not allowed](https://flink.apache.org/contributing/code-style-and-quality-common.html#avoid-mockito---use-reusable-test-implementations) to use `Mockito` within Flink. Can you please reimplement using a reusable test implementation instead? There are some examples [here](https://github.com/apache/flink/blob/master/flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/testutils/FakeKinesisBehavioursFactory.java)



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxyTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import org.apache.flink.streaming.connectors.kinesis.model.StreamShardHandle;
+
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.model.GetShardIteratorRequest;
+import com.amazonaws.services.kinesis.model.GetShardIteratorResult;
+import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
+import com.amazonaws.services.kinesis.model.Shard;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
+/** Test for methods in the {@link DynamoDBStreamsProxy} class. */
+public class DynamoDBStreamsProxyTest {
+
+    @Test

Review Comment:
   Please implement test using junit 5 (jupiter) and AssertJ as per the [code style guide](https://flink.apache.org/contributing/code-style-and-quality-common.html#tooling)



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


[GitHub] [flink] dannycranmer commented on pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on PR #21102:
URL: https://github.com/apache/flink/pull/21102#issuecomment-1300024465

   @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


[GitHub] [flink] elphastori commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
elphastori commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010262475


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxyTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import org.apache.flink.streaming.connectors.kinesis.model.StreamShardHandle;
+
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.model.GetShardIteratorRequest;
+import com.amazonaws.services.kinesis.model.GetShardIteratorResult;
+import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
+import com.amazonaws.services.kinesis.model.Shard;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
+/** Test for methods in the {@link DynamoDBStreamsProxy} class. */
+public class DynamoDBStreamsProxyTest {
+
+    @Test

Review Comment:
   Used junit 5 for new test - `import org.junit.jupiter.api.Test;` and confirmed that AssertJ is used instead of Hamcrest, JUnit assertions or assert.



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


[GitHub] [flink] elphastori commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
elphastori commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010280508


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxyTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import org.apache.flink.streaming.connectors.kinesis.model.StreamShardHandle;
+
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.model.GetShardIteratorRequest;
+import com.amazonaws.services.kinesis.model.GetShardIteratorResult;
+import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
+import com.amazonaws.services.kinesis.model.Shard;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
+/** Test for methods in the {@link DynamoDBStreamsProxy} class. */
+public class DynamoDBStreamsProxyTest {
+
+    @Test

Review Comment:
   Thank you. I've changed to package protected and I can confirm that the test is still being run.
   ```
   [INFO] Running org.apache.flink.streaming.connectors.kinesis.proxy.DynamoDBStreamsProxyTest
   [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.191 s - in org.apache.flink.streaming.connectors.kinesis.proxy.DynamoDBStreamsProxyTest
   ```



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


[GitHub] [flink] elphastori commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
elphastori commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1009635044


##########
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxy.java:
##########
@@ -110,6 +111,24 @@ public GetShardListResult getShardList(Map<String, String> streamNamesWithLastSe
         return result;
     }
 
+    @Override
+    public String getShardIterator(
+            StreamShardHandle shard, String shardIteratorType, @Nullable Object startingMarker)
+            throws InterruptedException {
+        try {
+            return super.getShardIterator(shard, shardIteratorType, startingMarker);
+        } catch (ResourceNotFoundException re) {
+            if (LOG.isInfoEnabled()) {
+                LOG.info(
+                        "Received ResourceNotFoundException. "
+                                + "Shard {} of stream {} is no longer valid, marking it as complete.",
+                        shard.getShard().getShardId(),
+                        shard.getStreamName());
+            }
+            return null;
+        }
+    }
+

Review Comment:
   Thanks, that's a good catch. From analysing the code, `getShardIterator` is only called after `getShardList`, particularly in the `DynamoDBStreamsProxy` which guarantees that deleted streams/tables throw an unhandled `NoResourceFoundException`.
   
   This is for both when the job is
   - starting (with and without a savepoint)
   - running - the consumer is discovering new shards.
   
   I've now the tested the following scenarios to verify the analysis - the failure modes have not changed
   - Starting the Flink job with or without a savepoint for a recently deleted stream/table (< 24 hrs) results in all shards getting closed - the DDB streams service returns a stream with `null` shard iterators
   - Deleting a table/stream on the fly also results in all shards getting closed
   - Using a stream/table that has been deleted for more than 24 hrs (or providing an altogether incorrect stream/table name) results in the job failing with a `NoResourceFoundException` thrown in `getShardList`



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


[GitHub] [flink] dannycranmer commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010265595


##########
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxy.java:
##########
@@ -110,6 +111,24 @@ public GetShardListResult getShardList(Map<String, String> streamNamesWithLastSe
         return result;
     }
 
+    @Override
+    public String getShardIterator(
+            StreamShardHandle shard, String shardIteratorType, @Nullable Object startingMarker)
+            throws InterruptedException {
+        try {
+            return super.getShardIterator(shard, shardIteratorType, startingMarker);
+        } catch (ResourceNotFoundException re) {
+            if (LOG.isInfoEnabled()) {

Review Comment:
   nit: I do not think this adds any value, since the check is performed under the hood. 



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


[GitHub] [flink] elphastori commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
elphastori commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010288812


##########
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxy.java:
##########
@@ -110,6 +111,24 @@ public GetShardListResult getShardList(Map<String, String> streamNamesWithLastSe
         return result;
     }
 
+    @Override
+    public String getShardIterator(
+            StreamShardHandle shard, String shardIteratorType, @Nullable Object startingMarker)
+            throws InterruptedException {
+        try {
+            return super.getShardIterator(shard, shardIteratorType, startingMarker);
+        } catch (ResourceNotFoundException re) {
+            if (LOG.isInfoEnabled()) {

Review Comment:
   Sorry, I didn't realise you were referring to the logging check. Thanks for confirming that it's performed under the hood, I'm removing it (and leaving the log).



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


[GitHub] [flink] dannycranmer commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1009223130


##########
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxy.java:
##########
@@ -110,6 +111,24 @@ public GetShardListResult getShardList(Map<String, String> streamNamesWithLastSe
         return result;
     }
 
+    @Override
+    public String getShardIterator(
+            StreamShardHandle shard, String shardIteratorType, @Nullable Object startingMarker)
+            throws InterruptedException {
+        try {
+            return super.getShardIterator(shard, shardIteratorType, startingMarker);
+        } catch (ResourceNotFoundException re) {
+            if (LOG.isInfoEnabled()) {
+                LOG.info(
+                        "Received ResourceNotFoundException. "
+                                + "Shard {} of stream {} is no longer valid, marking it as complete.",
+                        shard.getShard().getShardId(),
+                        shard.getStreamName());
+            }
+            return null;
+        }
+    }
+

Review Comment:
   Thanks for the contribution @elphastori. What is the failure mode difference from before until now if the user deletes a stream/table? Is there a possibility for regression or are DDB shard names typically unique?



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


[GitHub] [flink] dannycranmer commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010268760


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxyTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import org.apache.flink.streaming.connectors.kinesis.model.StreamShardHandle;
+
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.model.GetShardIteratorRequest;
+import com.amazonaws.services.kinesis.model.GetShardIteratorResult;
+import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
+import com.amazonaws.services.kinesis.model.Shard;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
+/** Test for methods in the {@link DynamoDBStreamsProxy} class. */
+public class DynamoDBStreamsProxyTest {
+
+    @Test

Review Comment:
   Best practise for junit 5 is for package protected method scope. Here is an example https://github.com/apache/flink/pull/19688/files



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


[GitHub] [flink] dannycranmer merged pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer merged PR #21102:
URL: https://github.com/apache/flink/pull/21102


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


[GitHub] [flink] elphastori commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
elphastori commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010278585


##########
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxy.java:
##########
@@ -110,6 +111,24 @@ public GetShardListResult getShardList(Map<String, String> streamNamesWithLastSe
         return result;
     }
 
+    @Override
+    public String getShardIterator(
+            StreamShardHandle shard, String shardIteratorType, @Nullable Object startingMarker)
+            throws InterruptedException {
+        try {
+            return super.getShardIterator(shard, shardIteratorType, startingMarker);
+        } catch (ResourceNotFoundException re) {
+            if (LOG.isInfoEnabled()) {

Review Comment:
   I agree, we risk polluting the logs for no value. Can have a comment here instead to note that sometimes the API provides invalid shards?
   ```
   // describeStream also returns shards that are no longer valid which need to be marked as complete.
   ```



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


[GitHub] [flink] elphastori commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
elphastori commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010254322


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxyTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.connectors.kinesis.proxy;
+
+import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import org.apache.flink.streaming.connectors.kinesis.model.StreamShardHandle;
+
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.model.GetShardIteratorRequest;
+import com.amazonaws.services.kinesis.model.GetShardIteratorResult;
+import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
+import com.amazonaws.services.kinesis.model.Shard;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
+/** Test for methods in the {@link DynamoDBStreamsProxy} class. */
+public class DynamoDBStreamsProxyTest {
+
+    @Test
+    public void testGetShardIterator() throws Exception {
+        // given
+        String fakeStreamName = "fake-stream";
+
+        List<String> shardIds =
+                Arrays.asList(
+                        "shardId-000000000000",
+                        "shardId-000000000001",
+                        "shardId-000000000002",
+                        "shardId-000000000003");
+
+        String invalidShardId = "shardId-000000000004";
+
+        AmazonKinesis mockClient = mock(AmazonKinesis.class);

Review Comment:
   I've removed `Mockito` and reimplemented the test using a `FakeKinesisClientFactory`.



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


[GitHub] [flink] dannycranmer commented on a diff in pull request #21102: [FLINK-26890][Connector/Kinesis] Handle invalid shards in DynamoDB

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #21102:
URL: https://github.com/apache/flink/pull/21102#discussion_r1010285336


##########
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/DynamoDBStreamsProxy.java:
##########
@@ -110,6 +111,24 @@ public GetShardListResult getShardList(Map<String, String> streamNamesWithLastSe
         return result;
     }
 
+    @Override
+    public String getShardIterator(
+            StreamShardHandle shard, String shardIteratorType, @Nullable Object startingMarker)
+            throws InterruptedException {
+        try {
+            return super.getShardIterator(shard, shardIteratorType, startingMarker);
+        } catch (ResourceNotFoundException re) {
+            if (LOG.isInfoEnabled()) {

Review Comment:
   Given the expected frequency of this (edge case), we should leave the log here. 



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