I have a client which performs the following two operations in order:
- Creates a new item with key "ABC123".
- Updates item "newestKey" to contain the value "ABC123".
Meanwhile a second client is running the following program:
- Read the item "newestKey" to get the key K of the newest item.
- Read item K.
Is it possible for the second client to get "ABC123" as the "newestKey" but then receive a not found error when it tries to load the item "ABC123" because the item hasn't yet propagated through the database?
In other words, is it guaranteed that if a single client makes two writes to the database then no client will ever see the second write unless it also sees the first write?
DynamoDB, despite its name, isn't based on the Dynamo whitepaper that inspired Riak, so I can't speak to that part of the question.
With Riak, there are relatively few guarantees due to its prioritization of availability over consistency. Because network partitions happen, it is always a possibility that a client may be able to read the object (let's call it "INDEX123") that includes the key "ABC123" but may not be able to reach a server that has the "ABC123" key/value pair.
Setting aside the situation where either the network is severely impaired or servers have failed, and if the following conditions are true, then I cannot think of a scenario where a client could read the key "ABC123" from "INDEX123" but not find the key/value pair "ABC123":
Given those conditions, here is an example of how server failures could prevent a client from being able to find the new key/value pair "ABC123", but only temporarily.
At that point, the client would be informed that no such data item exists, but Riak would, upon receipt of the key/value pair from the server that has a copy, push it to the servers that do not, and any future client requests would find it.
This repair operation is called "read repair". Riak also has an active anti-entropy mechanism to proactively identify missing/inconsistent data items and repair them.