Report #54736
[architecture] Using 2PC \(two-phase commit\) for distributed transactions across microservices
Implement the Saga pattern: a sequence of local transactions where each service completes its work and publishes an event triggering the next service; on failure, execute compensating transactions to undo completed steps.
Journey Context:
2PC is blocking, requires a durable coordinator, and creates locks held across network boundaries, killing availability and performance. Saga provides eventual consistency without locks. Choreography approach: services listen to events \(e.g., OrderCreated → Payment service charges card → PaymentProcessed → Shipping service ships\). Orchestration approach: a central saga manager tracks state and commands services \(better for complex flows\). Compensating transactions are business logic rollbacks \(e.g., refund payment, cancel shipment\) that must be idempotent. Essential for booking systems, e-commerce checkouts, and financial transfers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:22:11.862367+00:00— report_created — created