- Newest
- Most votes
- Most comments
The accepted answer to this question is wrong.
When a write happens to DynamoDB (conditional or otherwise), it is accepted by a leader node, which asynchronously replicates to at least 2 followers. A success response (200) is only returned when one of the followers acknowledges the write. This means that 2/3 of the replicas hold the latest data. However, an eventually consistent read can still be directed to the third replica, which has not yet caught up, returning stale data.
Writes to DynamoDB are strongly serialized by a leader node, along with strongly consistent reads. Writes never perform read operations, so you never need to worry about the consistency of a write (conditional or otherwise).
TLDR; An eventually consistent read can always return stale data. If you need the latest data, perform a strongly consistent read.
What happens when my leader node goes down given DynamoDB responded with success when 1 follower returned success and my next follower doesn't have the updates yet or failed to get updated
- Will my writes be affected (availability go down) until all replicas/followers come in sync?
- If no to 1 and If a new leader will be elected and writes don't perform reads, how do we ensure the new leader has the latest data? The new leader could be the one who doesn't have latest data yet and my condition is evaluated incorrectly?
- If no to 1 and 2, If the request is simply redirected to next node in preference list, it is possible that it doesn't have latest data and my condition is evaluated incorrectly?
DynamoDB ensures the condition check during a putItem operation is based on the latest data in the table. This means the condition is evaluated using a strongly consistent read to ensure that the condition is checked against the most recent data before the write is applied.
When a conditional putItem operation is performed, DynamoDB ensures that the write is committed across all replicas before it returns success. This guarantees that the write is durable and replicated.
Conditional writes check their conditions against the most recently updated version of the item. Note that if the item did not previously exist or if the most recent successful operation against that item was a delete, then the conditional write will find no previous item.
Eventually consistent reads do not guarantee the latest data immediately after a write. To get strong consistency in reads, you need to use strongly consistent reads explicitly.
When a conditional putItem operation is performed, DynamoDB ensures that the write is committed across all replicas before it returns success. This guarantees that the write is durable and replicated.
If the write is committed across all replicas before it returns success, eventually consistent read i.e read going to any replica should give latest data. Will that not be the case?
yes, if your Read happens after the write (not in parallel)
Relevant content
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated a month ago
please accept the answer if it was useful