liveBook · Manning

ACID

As explained in Microservices Patterns, Second Edition

A database transaction that provides atomicity, consistency, isolation, and durability guarantees.

An ACID transaction groups operations into one unit of work: all changes take effect, or none do. It provides atomicity, consistency, isolation, and durability, defining a boundary for correctness, failure, and concurrent access. section 9.1.1 section 9.4

Choose the transaction approach according to service scope:

  • For operations local to one service, use an ACID transaction. section 9.4
  • For operations spanning services, use a saga of local ACID transactions. The saga itself lacks isolation, so it needs application-level safeguards; classic XA/2PC distributed transactions bring complexity and runtime coupling. section 9.2 section 9.4
BEGIN TRANSACTION

SELECT * FROM PRODUCTS WHERE PRODUCT_ID = ?

UPDATE CONSUMER
  SET AVAILABLE_CREDIT = AVAILABLE_CREDIT - ?
  WHERE CONSUMER_ID = ?
    AND AVAILABLE_CREDIT >= ?

INSERT INTO ORDERS (...) VALUES (...)
COMMIT TRANSACTION

The transaction groups a product lookup, a credit update, and an order insert into one explicit unit of work. section 9.1.1

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines transaction boundaries, commit and abort behavior, concurrency conflicts, and local-versus-distributed trade-offs.
Examples
Uses a product lookup, customer-credit update, and order insertion as a transaction example.
What you can do after
Apply ACID transactions to service-local operations and choose sagas for operations spanning services.
How it connects
Connects transactions to system commands, microservices, distributed transactions, and the Saga pattern.

Also explained in

Compare how 10 books explain ACID →

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.