10

How can I create a controlled BatchWriteItem fail in DynamoDB?

Basically, I want to have a way of simulating failure (break BatchWriteItem on purpose) in DynamoDB so I can make sure the logic that takes UnprocessedItems in response is working correctly.

From documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html

Typically, you would call BatchWriteItem in a loop. Each iteration would check for unprocessed items and submit a new BatchWriteItem request with those unprocessed items until all items have been processed.

Below are two similar solutions discussed that use do-while loop and callback:

JAVA with do-while:

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/batch-operation-document-api-java.html

NODE with callback:

How to handle UnprocessedItems using AWS JavaScript SDK (dynamoDB)?

How to prepare a "broken" BatchWriteItem request in order to test this?

Can DynamoDB end up in infinite loop? i.e. BatchWriteItem returns UnprocessedItems, the code takes UnprocessedItems and calls BatchWriteItem and returns UnprocessedItems again and again?

1 Answer 1

4

You will get failed BatchWriteItem when due to throttling on the individual tables. So if you want to test in this case, you must make your DynamoDB tables become throttling. Steps:

  1. Calculate Capacity write Unit of your DynamoDB table
  2. Implement a function which writes too many into DynamoDB and make it reach maximum Capacity Write Unit.
  3. Run your function BatchWriteItem. You will be able to get UnprocessedItems because your DynamoDb are throttling.
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this by setting the WCU on my table to 1. All I got instead was the response: {"__type":"com.amazonaws.dynamodb.v20120810#ProvisionedThroughputExceededException","message":"The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API."}. When requests did go through, I still got {"UnprocessedItems": {} }.
I also have the same issue, no UnprocessedItems, wonder if there is another way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.