Race condition in Amazon DynamoDB Streams Lambda Trigger

0

In Amazon DynamoDB Streams, when similar entries are added simultaneously to a DynamoDB table and you have a Lambda function processing the stream to count the number of events, is there a possibility of a race condition. will this condition occur if both similar entries are processed by the Lambda function at the same time? How can I make sure this race condition never happens?

2回答
2

DynamoDB Streams guarantees exactly once deliver of all mutations to items in the table. This is done by using the internal log sequence number in DynamoDB which is unique to every modification.

While it may seem that both mutations happened at the same time on the client side, each of those mutations carry a unique log sequence number, which ensures they all make it to the stream exactly once.

Exactly once delivery:

PUT item (LSN=001) on stream ONLY IF item (LSN=001) NOT EXISTS

Item ordering:

PUT item (LSN=002) on stream ONLY IF item (LSN=001) EXISTS

Streams and their behaviour is documented here

profile pictureAWS
エキスパート
回答済み 7ヶ月前
0

A DynamoDB stream is an ordered flow of information about changes to items in a DynamoDB table. When you enable a stream on a table, DynamoDB captures information about every modification to data items in the table.

Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record with the primary key attributes of the items that were modified. A stream record contains information about a data modification to a single item in a DynamoDB table. You can configure the stream so that the stream records capture additional information, such as the "before" and "after" images of modified items.

DynamoDB Streams helps ensure the following:

Each stream record appears exactly once in the stream.

For each item that is modified in a DynamoDB table, the stream records appear in the same sequence as the actual modifications to the item

See : https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html

profile pictureAWS
回答済み 7ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ