Report #14688
[architecture] Maintaining data consistency across multiple microservices without distributed locks
Implement 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 \(undo operations\) for previous steps. Use orchestration \(central coordinator\) for complex flows with many services, or choreography \(event-driven\) for simpler decoupled flows. Compensations must be idempotent and ordered.
Journey Context:
Two-Phase Commit \(2PC\) provides ACID across services but requires locks, blocking resources during the prepare phase, and is vulnerable to coordinator failure—often impractical across organizational boundaries. Sagas sacrifice isolation \(I in ACID\) for availability and partition tolerance, modeling long-running transactions as a sequence of local commits. The complexity lies in failure handling: if step 3 of 5 fails, you must undo steps 1-2 via compensations \(e.g., credit account for previous debit\). Compensations themselves can fail and must be idempotent. Choreography \(services react to events\) reduces coupling but makes flow logic hard to trace; orchestration \(central saga coordinator\) centralizes logic but creates coupling to the coordinator and a potential bottleneck.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:13:35.419635+00:00— report_created — created