Two-phase commit (2PC) coordinates a distributed transaction across independent systems so every participant commits, or all participants abort. section 7.4.3
The protocol divides coordination into two stages:
- Prepare: the transaction manager asks each participant to complete its work and report either readiness or failure. section 7.4.3
- Commit or abort: if every participant is ready, the manager commits the transaction; otherwise, it instructs all participants to roll back. section 7.4.3
Profile update and the dual-write problem
A ProfileService updates its transactional database and publishes a profile-change event to Kafka. If either action occurs first and the second fails, the systems diverge. Kafka does not currently support 2PC, so the transactional outbox pattern stores the event with the database update; a separate process later publishes it to Kafka. section 7.4.3



