liveBook · Manning

Serialization anomaly

As explained in Microservices Patterns, Second Edition

A concurrency anomaly in which the combined outcome of interleaved transactions or sagas is not equivalent to any serial execution.

A serialization anomaly occurs when concurrent sagas interleave and produce an outcome that no serial execution could produce. Because sagas lack isolation across services, correct local transactions do not guarantee that the combined result preserves business invariants. section 9.3.1

Common forms include:

  • Lost updates: one saga overwrites another’s change without detecting the conflict. section 9.3.1
  • Dirty reads, nonrepeatable reads, and phantom reads: saga steps observe uncommitted data or changing values and query results. section 9.3.1
  • Write skew: concurrent sagas update disjoint data after reading overlapping data, violating a business invariant. section 9.3.1
Figure 9.7 Concurrent execution of these two sagas leaves the system in an inconsistent state. The Create Order Saga overwrites the change to the Order state. The Cancel Order Saga releases credit that was never reserved.
anomaly example scenario 1

The concurrent create-order and cancel-order sagas illustrate an overwritten order state and credit released even though it was never reserved. section 9.3.1

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines the anomaly, names five forms, and explains why local transaction isolation cannot guarantee global saga isolation.
Examples
Uses concurrent create-order and cancel-order sagas to show overwritten order state and incorrect credit handling.
What you can do after
Evaluate concurrent saga outcomes for nonserializable interleavings and business-invariant violations.
How it connects
Connects sagas with microservices, transaction isolation, compensating transactions, and business invariants.

Also explained in

Compare how 2 books explain serialization anomaly →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.