Github user tzulitai commented on a diff in the pull request:
https://github.com/apache/flink/pull/2131#discussion_r68698386
--- 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 --
My reasoning for failing hard here and not in the `describeStream()`
operation for limit / provision throughput exceeded exceptions is that I think
rate exceeding for `getRecords()` on a single shard may be cause by numerous
reasons that the user should handle.
1. The user might have other non-Flink concurrent consumers reading the
same shard (Kinesis limits to 5 concurrent reads per shard.) The user should
either slow down the non-Flink consumers, or slow down our `ShardConsumer` by
adjusting the `KinesisConfigConstants.CONFIG_SHARD_GETRECORDS_IDLE_MILLIS` we
will be introducing in https://github.com/apache/flink/pull/2071.
2. The size of each record is too large, and the user needs to adjust
`KinesisConfigConstants.CONFIG_SHARD_GETRECORDS_MAX` to a smaller value.
`describeStream()` on the other hand is an internal operation we need to
continuously do, and make sure we get results for the connector to work.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---