2

Can we use DynamoDb optimistic locking with batchWriteItem request? AWS docs on Optimistic locking mention that a ConditionalCheckFailedException is thrown when the version value is different while updating the request. In case of batchWriteItem request, will the whole batch fail or only that record with a different version value? Will the record that failed due to different version value be returned as an unprocessed record?

1 Answer 1

3

You cannot. You can be sure by looking at the low level syntax and notice there’s no ability to specify a condition expression.

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html

Sign up to request clarification or add additional context in comments.

2 Comments

For optimistic locking we don't need to specify conditional check, DynamoDB will throw this exception if the version number in the write request is not the same as the one stored in db. What I wanted to know is if DynamoDB supports optimistic locking for each individual write item request in the batchWriteItem request or not.
The Java SDK has to use the conditional expression functionality to achieve that optimistic locking behavior. Since the wire protocol doesn’t support it, Java can’t do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.