Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do DynamoDB's conditional updates work with its eventual consistency model?

I was reading the DynamoDB documentation and found two interesting features:

  1. Eventual consistent reads
  2. Strongly consistent reads
  3. Conditional updates

My question is, how do these three things interact with each other? Mostly I'm wondering if they conditional updates use a strongly consistent reads for checking the condition, or do they use eventually consistent reads? If it's the later, there is still a race condition, correct?

like image 512
Max Avatar asked Sep 26 '22 13:09

Max


1 Answers

For a conditional update you need strong consistency. I am going to guess that an update is a separate operation in which consistent read + write happen atomically and fail/succeeded together.

The way to think of Dynamo is like a group of separated entities that all keep track of the state and inform each other of updates that are made / agree if such updates can be propagated to the whole group or not.

When you (dynamo api on your behalf) write you basically inform a subset of these entities that you want to update data. After that the data propagates to all of these entities.

When you do an eventual consistent read you read it from one of the entities. It's eventual consistent meaning that there is a possibility that you will read from one of the entities that did not get the memo yet.

When doing a strong consistent read you read from enough entities to ensure that what you're read has propagated. If propagation is in progress you need to wait.

like image 131
Mircea Avatar answered Sep 29 '22 07:09

Mircea