Are single-client writes strongly ordered in DynamoDB or Riak?

181 views Asked by At

I have a client which performs the following two operations in order:

  1. Creates a new item with key "ABC123".
  2. Updates item "newestKey" to contain the value "ABC123".

Meanwhile a second client is running the following program:

  1. Read the item "newestKey" to get the key K of the newest item.
  2. 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?

1

There are 1 answers

2
macintux On BEST ANSWER

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":

  • The key/value pair represented by "ABC123" is a new one (and not an update to an older object with the same key)
  • The request parameters on all operations (such as W, R, and DW) are at the default values of 2 (assuming N=3)
  • The two operations you describe are successful

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.

  1. The key/value pair "ABC123" is successfully written to only 2 of the primary servers where it is supposed to live. The 3rd server receives and confirms the write, but due to disk failure or other transitory glitch it does not write the value to permanent storage
  2. 1 of the 2 servers that does contain the key/value pair fails
  3. A client requests the key/value pair, and the first servers to respond to the request are the server that originally failed to write the pair and a failover server that has assumed the role of the server that failed in step #2

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.