Are Dynamodb conditional expressions consistent across nodes?

0

I am trying to lock an object in a table with a function that looks like this:

def lock(): dynamodb = boto3.resource('dynamodb', endpoint_url="http://localhost:8000")

table = dynamodb.Table('table')

response = table.update_item(
    Key={
        'id': "id1",
        'created_at': "2022-02-06T12:07:45.602721617Z"
    },
    UpdateExpression="SET #O.L  = :locked",
    ConditionExpression="object.locked <> :locked",
    ExpressionAttributeValues={':locked': True},
    ReturnValues="UPDATED_NEW"
)
return response

Given that several workers might be trying to get the lock at the same time and there is no way to have consistent write in Dynamodb. Is it possible for multiple workers to acquire the lock at the same time?

已提問 2 年前檢視次數 810 次
1 個回答
1
已接受的答案

All writes to DynamoDB are singleton and consistent. There is only a chance for a single thread to acquire the lock, all others will fail. More here.

Reads on the other hand can be both Eventually Consistent or optionally Strongly Consistent. More here.

profile pictureAWS
專家
已回答 2 年前
  • When we use conditional expression in save operation (with Save expression), does the read for that conditional expression is strongly consistent?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南