Report #25514
[architecture] Maintaining ACID consistency across microservices without blocking resources
Implement the Saga pattern using orchestration or choreography where each service performs local transactions and emits domain events; if a step fails, execute compensating transactions to undo completed steps, rather than using two-phase commit \(2PC\).
Journey Context:
Architects often reach for distributed transactions \(2PC/XA protocols\) when crossing service boundaries, but this creates a tight coupling: the transaction coordinator becomes a single point of failure, and resource managers hold locks during the prepare phase, causing latency and deadlock under load. The Saga pattern accepts eventual consistency between services and handles failure through compensation logic. Orchestration \(central coordinator\) vs choreography \(event-driven\) is a secondary choice: orchestration is easier to trace and debug for complex flows, while choreography reduces coupling but makes the flow implicit in the code. The critical insight is that compensations must be idempotent and order-independent where possible; a common error is writing compensations that assume the original transaction definitely succeeded, but partial failures and message duplication mean compensations may run against partially applied states or be retried.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:13:46.556509+00:00— report_created — created