Report #86077
[architecture] Maintaining data consistency across microservices without 2PC locks
Use the Saga pattern with orchestration: for each business transaction, create a saga state machine that emits domain events via an Outbox pattern \(events stored in same DB transaction as business data, then polled by a relay to message broker\); compensate on failure, never locking resources across services.
Journey Context:
Developers often try to use distributed transactions \(2PC/XA\) across microservices, which creates tight coupling, cascading failures, and performance death \(all resources locked during prepare phase\). Alternatively, "best effort" messaging without the Outbox leads to dual-write problems \(DB commits but message fails, or vice versa\). The Saga pattern models a long-lived transaction as a sequence of local transactions, each publishing an event triggering the next step. The Outbox pattern guarantees exactly-once message delivery by treating the event table as part of the ACID business transaction, then using a separate process \(CDC or polling publisher\) to relay to Kafka/RabbitMQ. This decouples services temporally and failure-domain wise, at the cost of eventual consistency and complexity of compensation logic \(which must be idempotent\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:04:14.794740+00:00— report_created — created