4
votes

I have a DynamoDB table where I am using transactional writes (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transactions.html). The transaction consists of 2 puts. Let's say the first put succeeds and the second fails. In this scenario, the first put will be rolled back by the transaction library.

I also have DynamoDB streams (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html) enabled on the table and another application consumes from that stream.

Question: In the rollback scenario, will the first successful put result in a DynamoDB stream event and the rollback will result in another? If yes, is there is a way to prevent this, that is, to ensure that a stream event is triggered only for a fully completed transaction?

1

1 Answers

6
votes

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis.html

Changes made with transactions are propagated to global secondary indexes (GSIs), DynamoDB streams, and backups eventually, after the transaction completes successfully. Because of eventual consistency, tables restored from an on-demand or point-in-time-recovery (PITR) backup might contain some but not all of the changes made by a recent transaction.

So As I read it, you won't see anything in the stream till after the transaction completes successfully.