Report #3855
[architecture] Maintaining data consistency across microservices without blocking 2PC/XA transactions
Use the Saga pattern: sequence local transactions where each service updates its data and publishes an event or command to trigger the next step. If a step fails, execute compensating transactions \(semantic undo\) to rollback previous steps. Never use two-phase commit \(2PC\) across HTTP microservices.
Journey Context:
Developers often try to use distributed transactions \(2PC/XA\) to keep microservices ACID, but this creates tight coupling, requires all participants to be available during the commit phase \(blocking\), and is incompatible with HTTP/REST. The Saga pattern accepts eventual consistency and models business processes as a sequence of local transactions. If step 3 fails, steps 1 and 2 run compensations \(e.g., credit back money if inventory reservation failed\). There are two flavors: Choreography \(event-driven, decentralized, uses event bus\) and Orchestration \(central coordinator commands services\). Tradeoffs: Sagas are complex to debug \(no central ACID log\), compensation logic must be idempotent, and there is a window of inconsistency between steps.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:20:05.278460+00:00— report_created — created