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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠