Tensorum

Distributed Transactions

Keeping invariants intact when one business operation spans several services or databases.

Distributed SystemsAdvanced6 hrs4 key ideas · 5 applied designs
0%
your progress

Overview

Keeping invariants intact when one business operation spans several services or databases.

Key ideas

  • Two-phase commit gives atomicity but blocks if the coordinator dies between prepare and commit.
  • Sagas replace one big transaction with local steps plus compensating actions.
  • The transactional outbox writes the event in the same local transaction as the state change, then relays it.
  • Design for idempotent steps so retries and replays are safe.

Trade-offs

  • 2PC: strong atomicity, poor availability and throughput.
  • Sagas: available and scalable, but intermediate states are visible and compensations must be designed.

In the real world

XA transactionsTemporal / Cadence workflowsDebezium outbox relays

Keywords

2PCSagaOutboxCompensation