Relative Content

Tag Archive for amazon-web-servicestransactionsamazon-dynamodblocking

DynamoDB All or Nothing Optimistic Locking

I have a serverless application using APIGateway, Lambda, and DynamoDB with NodeJS and typescript. I have a handful of situations were multiple clients could attempt to modify certain resources simultaneously. These race conditions usually involve querying a record, making a decision on how it should be modified, and then running an update. Because of this, I have applied opportunistic locking via conditional expressions, and I use Date.now() as the version. Thus, I query the record, make a decision about how it should be modified, and if the conditional check fails, I can simply query the record again and make a potentially different decision. Opportunistic locking is a very natural solution.