Partial failure occurs when a remote service is unavailable or responds too slowly, or when a multi-step operation stops after only some state changes. In either case, other components may continue operating while the requested work remains incomplete. section 8.4 section 9.1.1
Choose safeguards according to where the failure occurs:
- For synchronous calls, handle partial failures with resiliency patterns such as circuit breakers to help prevent failures from cascading. section 8.4
- For commands with multiple state changes, use transaction boundaries to define whether the changes succeed or fail together. section 9.1.1
Creating an order
An order command can retrieve a product price, reserve customer credit, and insert an order. If it fails after only some changes, the system may be left 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 listing groups the order-related database operations behind a single commit boundary. section 9.1.1
