vogels
vogels copied to clipboard
Issue with consistent reading immediately after posting
Hello everyone!
When I insert a new item and try to read the updated table in the callback, only 70-80% of the times I get updated value. Other times it sends old data.
I have enabled consistent read and my data is also just a couple of rows for now :(
Any idea why this might be happening? Has anyone ever faced this?
Thanks, Vikas
This is from the DynamoDB documentation:
DynamoDB maintains multiple copies of each item to ensure durability. For every
successful write request, DynamoDB ensures that the write is durable on multiple servers.
However, it takes time for a write to propagate to all copies. In DynamoDB, data is
eventually consistent. This means that if you write an item and then immediately try to
read it, you might not see the results from the earlier write.
By default, a GetItem operation performs an eventually consistent read. You can optionally
request a strongly consistent read instead; this will consume additional read capacity
units, but it will return the most up-to-date version of the item.
An eventually consistent GetItem request consumes only half the read capacity units as
a strongly consistent request. Therefore, it is best to design applications so that they use
eventually consistent reads whenever possible. Consistency across all copies of the data
is usually reached within one second.
@set-killer Yup, I am aware of it. That's why I have enabled strongly consistent option by setting ConsistentRead to true.
But it is not working as expected.
Can you post some code? Thanks