From 4ab69659d3f2060da0f5620240328ea253bdcba4 Mon Sep 17 00:00:00 2001 From: Nicholas Watkins <5408930+rin1221@users.noreply.github.com> Date: Fri, 9 Mar 2018 10:59:16 -0600 Subject: [PATCH 1/3] Added parameter to set AWS SDK MaxRetries --- physical/dynamodb/dynamodb.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/physical/dynamodb/dynamodb.go b/physical/dynamodb/dynamodb.go index bd12c47d45a3..16a460e3e8d4 100644 --- a/physical/dynamodb/dynamodb.go +++ b/physical/dynamodb/dynamodb.go @@ -183,6 +183,18 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac } } + dynamodbMaxRetryString := os.Getenv("AWS_DYNAMODB_MAX_RETRIES") + if dynamodbMaxRetryString == "" { + dynamodbMaxRetryString = conf["dynamodb_max_retries"] + if dynamodbMaxRetryString == "" { + dynamodbMaxRetryString = "0" + } + } + dynamodbMaxRetry, err := strconv.Atoi(dynamodbMaxRetryString) + if err != nil { + return nil, fmt.Errorf("invalid max retry: %s", dynamodbMaxRetryString) + } + credsConfig := &awsutil.CredentialsConfig{ AccessKey: accessKey, SecretKey: secretKey, @@ -202,7 +214,8 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac WithEndpoint(endpoint). WithHTTPClient(&http.Client{ Transport: pooledTransport, - }) + }). + WithMaxRetries(dynamodbMaxRetry) client := dynamodb.New(session.New(awsConf)) if err := ensureTableExists(client, table, readCapacity, writeCapacity); err != nil { From 1daff469193dc920ba49683555cae95c54e0fdf7 Mon Sep 17 00:00:00 2001 From: Nicholas Watkins <5408930+rin1221@users.noreply.github.com> Date: Wed, 14 Mar 2018 10:55:44 -0500 Subject: [PATCH 2/3] Make unassigned value for the Dynamodb MaxRetries AWS Default Set the value of the Dynamodb MaxRetries to -1 as the aws sdk uses the default value when that is given as stated in the MaxRetries comments in the following link. https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config --- physical/dynamodb/dynamodb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physical/dynamodb/dynamodb.go b/physical/dynamodb/dynamodb.go index 16a460e3e8d4..07456c627ad0 100644 --- a/physical/dynamodb/dynamodb.go +++ b/physical/dynamodb/dynamodb.go @@ -187,7 +187,7 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac if dynamodbMaxRetryString == "" { dynamodbMaxRetryString = conf["dynamodb_max_retries"] if dynamodbMaxRetryString == "" { - dynamodbMaxRetryString = "0" + dynamodbMaxRetryString = "-1" } } dynamodbMaxRetry, err := strconv.Atoi(dynamodbMaxRetryString) From 665d1f6ac98998885d6023c4d3bc8014becbf856 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 19 Mar 2018 15:52:48 -0400 Subject: [PATCH 3/3] Update dynamodb.go --- physical/dynamodb/dynamodb.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/physical/dynamodb/dynamodb.go b/physical/dynamodb/dynamodb.go index 07456c627ad0..eaa36afb0899 100644 --- a/physical/dynamodb/dynamodb.go +++ b/physical/dynamodb/dynamodb.go @@ -186,13 +186,14 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac dynamodbMaxRetryString := os.Getenv("AWS_DYNAMODB_MAX_RETRIES") if dynamodbMaxRetryString == "" { dynamodbMaxRetryString = conf["dynamodb_max_retries"] - if dynamodbMaxRetryString == "" { - dynamodbMaxRetryString = "-1" - } } - dynamodbMaxRetry, err := strconv.Atoi(dynamodbMaxRetryString) - if err != nil { - return nil, fmt.Errorf("invalid max retry: %s", dynamodbMaxRetryString) + var dynamodbMaxRetry int = aws.UseServiceDefaultRetries + if dynamodbMaxRetryString != "" { + var err error + dynamodbMaxRetry, err = strconv.Atoi(dynamodbMaxRetryString) + if err != nil { + return nil, fmt.Errorf("invalid max retry: %s", dynamodbMaxRetryString) + } } credsConfig := &awsutil.CredentialsConfig{