Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB concurrent write

I have an existing DynamoDB table which has attributes say

---------------------------------------------------------
hk(hash-key)| rk(range-key)|   a1    |    a2   |    a3   | 
---------------------------------------------------------


I have an existing DynamoDb client which will only update existing record for a1 only. I want to create a second writer(DDB client) which will also update an existing record, but, for a2 and a3 only.
If both the ddb client tries to update same record (1 for a1 and other for a2 and a3) at the exact same time, will DynamoDb guarantee that all a1 a2 a3 are updated with correct value(all three new values)? Is using save behavior UPDATE_SKIP_NULL_ATTRIBUTES sufficient for this purpose or do I need to implement some kind of optimistic locking? If not, Is there something that DDB provides on the fly for this purpose?

like image 698
Deepankar Singh Avatar asked Dec 18 '17 14:12

Deepankar Singh


1 Answers

If you happen to be using the Dynamo Java SDK you are in luck, because the SDK supports just that with Optimistic Locking. Im not sure if the other SDKs support anything similar - I suspect they do not.

Optimistic locking is a strategy to ensure that the client-side item that you are updating (or deleting) is the same as the item in DynamoDB. If you use this strategy, then your database writes are protected from being overwritten by the writes of others — and vice-versa.

like image 65
F_SO_K Avatar answered Sep 22 '22 20:09

F_SO_K