awslabs / dynamodb-data-mapper-js

A schema-based data mapper for Amazon DynamoDB.
https://awslabs.github.io/dynamodb-data-mapper-js/
Apache License 2.0
816 stars 106 forks source link

`BatchWrite` doesn't handle `ProvisionedThroughputExceededException` #176

Open wjam opened 4 years ago

wjam commented 4 years ago

BatchWrite currently handles the situation where some of the writes have failed and BatchWrite will retry those records. However, the API says:

If none of the items can be processed due to insufficient provisioned throughput on all of the tables in the request, then BatchWriteItem returns a ProvisionedThroughputExceededException.

In this situation, the exception will be thrown at this line and simply left to bubble up the stack rather than retrying all items in the request. https://github.com/awslabs/dynamodb-data-mapper-js/blob/d52b9dfea14851235843a0879e5754822c0e462d/packages/dynamodb-batch-iterator/src/BatchWrite.ts#L49

In the situation that batchWriteItem throws a ProvisionedThroughputExceededException, then BatchWrite should add all items in the request back to the queue to be re-attempted.