Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS node.js automatic retry on failed batchWrite()

According to this aws doc http://docs.aws.amazon.com/general/latest/gr/api-retries.html automatic retry feature is build in the aws sdk in my case node.js aws sdk. I configured the DocumentClient object like this:

var dynamodb = new AWS.DynamoDB.DocumentClient({
    region: 'us-west-2',
    retryDelayOptions: {base: 50},
    maxRetries: 20
});

but I still cannot make it auto-retry for me. I want to auto-retry with all UnprocessedItems as well. Can you point me to where is my mistake?

Thanks

like image 209
Plamen Paskov Avatar asked Mar 27 '17 15:03

Plamen Paskov


2 Answers

The retryDelayOptions and maxRetries are the options present on AWS.DynamoDB. The DocumentClient has to be configured by setting the DynamoDB service.

var dynamodb = new AWS.DynamoDB({maxRetries: 5, retryDelayOptions: {base: 300} });
var docClient = new AWS.DynamoDB.DocumentClient({service : dynamodb});
like image 56
notionquest Avatar answered Oct 20 '22 17:10

notionquest


The AWS Client SDKs all have built-in mechanisms for retry indeed, however those retries are at the request level. That means that any request that gets rejected by the server with a 500-level error, or in some cases, a 400-level throttling error will get automatically retried based on the configured settings.

What you are asking for is business-layer retry behavior which is NOT built into the SDK. The UnprocessedItems collection contains items that were rejected by the service for various reasons and you have to write your own logic to handle those.

like image 36
Mike Dinescu Avatar answered Oct 20 '22 16:10

Mike Dinescu