pelaezryan opened a new pull request, #245: URL: https://github.com/apache/flink-connector-aws/pull/245
<!-- *Thank you for contributing to Apache Flink AWS Connectors - we are happy that you want to help us improve our Flink connectors. 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.* ## Contribution Checklist - The name of the pull request should correspond 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. - Commits should be in the form of "[FLINK-XXXX][component] Title of the pull request", where [FLINK-XXXX] should be replaced by the actual issue number. Generally, [component] should be the connector you are working on. For example: "[FLINK-XXXX][Connectors/Kinesis] XXXX" if you are working on the Kinesis connector or "[FLINK-XXXX][Connectors/AWS] XXXX" if you are working on components shared among all the connectors. - Each pull request should only have one JIRA issue. - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below. --> ## Purpose of the change - https://issues.apache.org/jira/browse/FLINK-39540 Address a bug in the Kinesis Flink Connector that would cause Enhanced Fan Out (EFO) customers to continously experience ``IllegalArgumentException`` when their stream is resharded. This occurs due to the subscription being restarted when it should be completed and cleaned up. Example of error: ``` [aws-java-sdk-NettyEventLoop-31-1] INFO org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription - Subscription complete - shardId-000000002053 (arn:aws:kinesis:us-east-1:123456:stream/test-source-stream/consumer/my-flink-efo-consumer:1774401121) [aws-java-sdk-NettyEventLoop-31-1] INFO org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription - Activating subscription to shard shardId-000000002053 with starting position StartingPosition{shardIteratorType=AFTER_SEQUENCE_NUMBER, startingMarker=null} for consumer arn:aws:kinesis:us-east-1:123456:stream/test-source-stream/consumer/my-flink-efo-consumer:1774401121. [aws-java-sdk-NettyEventLoop-31-1] ERROR software.amazon.awssdk.utils.async.FlatteningSubscriber - Unexpected exception encountered that violates the reactive streams specification. Attempting to terminate gracefully. java.lang.IllegalArgumentException: Invalid StartingPosition. When ShardIteratorType is AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER, startingMarker must be a String. at org.apache.flink.util.Preconditions.checkArgument(Preconditions.java:138) at org.apache.flink.connector.kinesis.source.split.StartingPositionUtil.toSdkStartingPosition(StartingPositionUtil.java:65) at org.apache.flink.connector.kinesis.source.proxy.KinesisAsyncStreamProxy.subscribeToShard(KinesisAsyncStreamProxy.java:56) at org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription.activateSubscription(FanOutKinesisShardSubscription.java:137) at org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription$FanOutShardSubscriber.onComplete(FanOutKinesisShardSubscription.java:334) at software.amazon.awssdk.utils.async.DelegatingSubscriber.onComplete(DelegatingSubscriber.java:47) ... ``` ## Verifying this change - *Manually verified by running the Kinesis connector on a local Flink cluster.* After making the change, i 1. re-ran my flink application, 2. resharded my stream. Afterwards verified that subscriptions were being shut down and restarted without issues: reshard ``` [Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.SourceReaderBase - Finished reading split(s) [shardId-000000003079] [Source Data Fetcher for Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher - Finished reading from splits [shardId-000000003079] [Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.SourceReaderBase - Finished reading split(s) [shardId-000000003080] [Source Data Fetcher for Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher - Finished reading from splits [shardId-000000003080] [Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.fetcher.SplitFetcherManager - Closing splitFetcher 0 because it is idle. [Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher - Shutting down split fetcher 0 [SourceCoordinator-Source: Kinesis source] INFO org.apache.flink.connector.kinesis.source.enumerator.KinesisStreamsSourceEnumerator - Assigning shard shardId-000000003081 from stream arn:aws:kinesis:us-east-1:890385144326:stream/test-source-stream to subtask 0. [Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.SourceReaderBase - Adding split(s) to reader: [KinesisShardSplit{streamArn='arn:aws:kinesis:us-east-1:890385144326:stream/test-source-stream', shardId='shardId-000000003081', startingPosition=StartingPosition{shardIteratorType=TRIM_HORIZON, startingMarker=null}, parentShardIds=[shardId-000000003079,shardId-000000003080], startingHashKey='0', endingHashKey='340282366920938463463374607431768211455', finished=false}] [Source Data Fetcher for Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher - Split fetcher 0 exited. [Source Data Fetcher for Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher - Starting split fetcher 1 [Source Data Fetcher for Source: Kinesis source -> (Sink: Print to Std. Out, Kinesis sink: Writer) (1/1)#0] INFO org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription - Activating subscription to shard shardId-000000003081 with starting position StartingPosition{shardIteratorType=TRIM_HORIZON, startingMarker=null} for consumer arn:aws:kinesis:us-east-1:890385144326:stream/test-source-stream/consumer/my-flink-efo-consumer:1774401121. [aws-java-sdk-NettyEventLoop-2-10] INFO org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription - Successfully subscribed to shard shardId-000000003081 at StartingPosition{shardIteratorType=TRIM_HORIZON, startingMarker=null} using consumer arn:aws:kinesis:us-east-1:890385144326:stream/test-source-stream/consumer/my-flink-efo-consumer:1774401121. [ForkJoinPool.commonPool-worker-4] INFO org.apache.flink.connector.kinesis.source.reader.fanout.FanOutKinesisShardSubscription - Successfully subscribed to shard shardId-000000003081 with starting position StartingPosition{shardIteratorType=TRIM_HORIZON, startingMarker=null} for consumer arn:aws:kinesis:us-east-1:890385144326:stream/test-source-stream/consumer/my-flink-efo-consumer:1774401121. ``` ## Significant changes N/A - Not a significant change -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
