An invariant is a condition that must remain true for application data or system state to be valid. System commands may need to preserve one across several state changes, such as keeping inventory from being oversold or a customer within their credit limit. section 9.1.1
A transaction groups operations behind a correctness boundary: it commits only when every operation succeeds and required invariants hold. On failure, it aborts or undoes its effects so partial changes do not leave the system inconsistent. section 9.1.1
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
This transaction conditionally deducts customer credit only when enough is available, inserts the order, and commits the grouped changes. section 9.1.1
Concurrent sagas
Create Order and Cancel Order sagas can interleave so that an order is overwritten, credit is released without having been reserved, or an order succeeds despite insufficient available credit. These outcomes violate business invariants even when each service enforces local transaction rules. section 9.3.1

















