liveBook · Manning

Concurrency control

As explained in Microsoft Azure in Action

Concurrency control is the management of simultaneous operations so that shared data remains consistent according to the system's rules.

Concurrency control keeps simultaneous operations from corrupting shared data. In Azure Cosmos DB, optimistic concurrency lets operations proceed without locking, then checks for conflicts before accepting an update. section 11.4.3

Cosmos DB uses a version-checking workflow:

  • A read stores the document’s ETag, which represents its current version. section 11.4.3
  • An update includes that ETag and succeeds only if the document has not changed since it was read. section 11.4.3
  • If another operation changed the document, the ETag no longer matches and the update fails instead of overwriting newer data. section 11.4.3
  • The application can retry the read-update cycle using the latest document version. section 11.4.3

Updating inventory during a busy sale

Suppose two shoppers trigger inventory updates for the same product. Each operation reads the product and its ETag. The first update changes the document and its ETag; the second update detects the mismatch, fails safely, and can reread the inventory before retrying. section 11.4.3

Figure 11.7 A read operation stores the ETag value for concurrency in future updates.

A read operation stores the ETag for use in a later conditional update. section 11.4.3

How Microsoft Azure in Action covers it

How deep it goes
Explains optimistic concurrency, ETag checks, conflict failure, and read-update retries without detailing transaction internals.
Examples
Uses concurrent product-inventory updates and a read operation that stores an ETag for a later update.
What it assumes
Assumes Azure Cosmos DB documents and simultaneous operations; teaches ETags and optimistic conflict handling directly.
What you can do after
Diagnose/debug with it: detect stale updates through ETag mismatches and retry the read-update cycle safely.
How it connects
Connects optimistic concurrency with ETags, transactions, data consistency, and Azure Cosmos DB documents.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.