Dual-write problem.
also: dual write · dual-write · dual writes · dual-writesWriting to two systems (the database and a message broker) in one operation without atomicity, so a crash can leave them disagreeing.
the two-minute refresher
- Save the order, then publish OrderCreated: the process can crash between the two.
- Result: an order with no event, or an event for an order that rolled back.
- 2PC across a database and Kafka is not an option (Kafka doesn't support XA).
- Fix: write once (DB + outbox in one transaction) and derive the event from it.