Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force delete on table that uses optimistic locking with version number

I have a Dynamo table that uses optimistic locking via the DynamoDBVersionAttribute to ensure that only one worker at a time has a document reserved. However, when I want to clean up a document, the delete throws a ConditionalCheckFailedException when I don't set the version in the DynamoDBMapper.

At that point, I don't care what version the document is, and I want to delete it no matter what version it is. Is there a way to force the delete without worrying about the version? I want to overcome the exception without having to query Dynamo for the document.

like image 771
EmptyArsenal Avatar asked Dec 28 '25 09:12

EmptyArsenal


1 Answers

You can delete the item by specifying the SaveBehaviour as CLOBBER without worrying about the version.

DynamoDBMapper mapper;
mapper.delete(object, new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.CLOBBER)
like image 107
vivek Avatar answered Dec 30 '25 22:12

vivek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!