liveBook · Manning

Optimistic locking

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

Optimistic locking is a concurrency-control technique in which an update succeeds only when the item's supplied version matches its current version.

Optimistic locking allows an update only when the supplied item version matches the current database version. The update then advances the version. section 16.3.2

DynamoDB provides the conditional-update features, but application code must implement the technique. A failed version check prevents a stale writer from overwriting newer data. section 16.3.2

Two processes update one item

An item starts at version 0. Processes A and B both read version 0. A updates successfully, and the item becomes version 1. B's update specifying version 0 is rejected; B must reread version 1 and retry its change. section 16.3.2

Use conditional expressions to require the expected version during updates. Under heavy parallel modification, repeated retries can create substantial overhead. section 16.3.2

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Defines version checks, walks through concurrent updates and retries, and notes overhead without detailing retry implementation.
Examples
Uses two processes reading version 0, one advancing to version 1, and the other retrying after rejection.
What you can do after
Apply it via DynamoDB conditional updates and retry rejected changes after rereading the item.
How it connects
Connects DynamoDB conditional updates with concurrency control and retry.

Also explained in

Compare how 2 books explain optimistic locking →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.