Github user tzulitai commented on a diff in the pull request: https://github.com/apache/flink/pull/2131#discussion_r68696712 --- Diff: flink-streaming-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/proxy/KinesisProxy.java --- @@ -86,32 +144,25 @@ public KinesisProxy(Properties configProps) { * @param maxRecordsToGet the maximum amount of records to retrieve for this batch * @return the batch of retrieved records */ - public GetRecordsResult getRecords(String shardIterator, int maxRecordsToGet) { + @Override + public GetRecordsResult getRecords(String shardIterator, int maxRecordsToGet) throws InterruptedException { final GetRecordsRequest getRecordsRequest = new GetRecordsRequest(); getRecordsRequest.setShardIterator(shardIterator); getRecordsRequest.setLimit(maxRecordsToGet); GetRecordsResult getRecordsResult = null; - int remainingRetryTimes = Integer.valueOf( - configProps.getProperty(KinesisConfigConstants.CONFIG_STREAM_DESCRIBE_RETRIES, Integer.toString(KinesisConfigConstants.DEFAULT_STREAM_DESCRIBE_RETRY_TIMES))); - long describeStreamBackoffTimeInMillis = Long.valueOf( - configProps.getProperty(KinesisConfigConstants.CONFIG_STREAM_DESCRIBE_BACKOFF, Long.toString(KinesisConfigConstants.DEFAULT_STREAM_DESCRIBE_BACKOFF))); - - int i=0; - while (i <= remainingRetryTimes && getRecordsResult == null) { + int attempt = 0; + while (attempt <= getRecordsMaxAttempts && getRecordsResult == null) { try { getRecordsResult = kinesisClient.getRecords(getRecordsRequest); } catch (ProvisionedThroughputExceededException ex) { + long backoffMillis = fullJitterBackoff( + getRecordsBaseBackoffMillis, getRecordsMaxBackoffMillis, getRecordsExpConstant, attempt++); LOG.warn("Got ProvisionedThroughputExceededException. Backing off for " - + describeStreamBackoffTimeInMillis + " millis."); - try { - Thread.sleep(describeStreamBackoffTimeInMillis); - } catch (InterruptedException interruptEx) { - // - } + + backoffMillis + " millis."); + Thread.sleep(backoffMillis); } - i++; } if (getRecordsResult == null) { --- End diff -- Misunderstanding here. The `getRecordsResult` will only be `null` here if we fail to get any response from Kinesis due to `ProvisionedThroughputExceededException` even after 3 retries (default setting of `KinesisConfigConstants.DEFAULT_SHARD_GETRECORDS_RETRIES`). We'll always get a `GetRecordsResult` regardless of the status of the shard. What the javadoc is saying is that if we reached the end of a shard (the shard is closed) `GetRecordsResult#getNextShardIterator()` will return a `null`, meaning that we won't be able to continue consuming the shard. In `ShardConsumer`, we always renew the `nextShardIterator` with the value returned in `GetRecordsResult`. If we get a `null`, we know the shard is closed and terminate the `ShardConsumer` thread. So, no more `getRecords()` calls will be made to the shard after it is closed.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---