Reputation: 3108
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:
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?
Upvotes: 9
Views: 4416
Reputation: 920
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:
BatchWriteItem
. You will be able to get UnprocessedItems
because your DynamoDb are throttling.Upvotes: 4