Report #64190
[architecture] Handling long-running distributed transactions across microservices without locking resources
Implement the Saga pattern using orchestration with compensating transactions: store saga state, execute steps sequentially, and if any step fails, run compensating transactions for completed steps to maintain consistency.
Journey Context:
Two-phase commit \(2PC\) blocks resources and fails if any participant is unavailable, making it unsuitable for long-running operations or microservices with independent databases. The Saga pattern treats each step as an independent local transaction; if step N fails, steps 1..N-1 are undone via compensating transactions \(e.g., if step 1 charged a credit card, step 1's compensation issues a refund\). Orchestration \(central coordinator\) is preferred over choreography \(event-driven\) for complex flows requiring explicit state tracking and failure handling. The common error is implementing 'best effort' sagas without compensation, leading to orphaned records or financial inconsistency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:13:55.727334+00:00— report_created — created