Report #70037
[architecture] How to maintain data consistency across microservices without distributed locks
Use the Saga pattern \(sequence of local transactions with compensating actions\) instead of Two-Phase Commit \(2PC\); prefer orchestrated sagas for complex flows, choreographed for simple event-driven ones.
Journey Context:
2PC locks resources across services during the prepare phase, creating tight coupling and blocking - violating microservice autonomy. If the coordinator fails, resources stay locked indefinitely. Sagas execute local commits sequentially; if step N fails, run compensating transactions \(e.g., credit account if debit succeeded\) for steps 1..N-1. Tradeoffs: eventual consistency, complex rollback logic, and lack of isolation \(dirty reads possible between steps\). Orchestrated sagas use a central coordinator \(easier to track state\), while choreographed sagas use events \(looser coupling, harder to debug\). Use sagas for long-lived transactions; avoid 2PC in microservices entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:08:08.660020+00:00— report_created — created