Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Distributed Transactions and Two-Phase Commit: Why They Are Avoided in Microservices
Two-phase commit (2PC) lets several participants commit or abort a transaction together, but if the coordinator crashes before deciding, participants that voted YES wait while holding their locks. System.Transactions runs 2PC with volatile participants; a second durable participant throws PlatformNotSupportedException on macOS and Linux. Because of availability, coupling and missing broker support, microservices use sagas and the outbox instead.
No Transactions Across Microservices: Embracing Eventual Consistency by Design
Distributed transactions (2PC) are not used across services; a rule that needs immediate consistency stays in one service, and a flow spanning several services is built with sagas and compensating actions, with events going through an outbox. The real error TransactionScope gives on Linux and macOS, a choreographed checkout saga, intermediate states in the domain, and eventual consistency shown to the user with 202 Accepted.