Distributed Transactions: Orchestrated Saga with Compensating Actions
Buy one iPhone across an order service, a payment service and an inventory service, each with its own database. Break a different step each time and watch the orchestrator undo what already succeeded, in reverse order, even when the undo itself fails.
Time35 minutes
StackPython 3Ports 15470, 15471, 15472
MemoryAbout 140 MB
Before thisLab 41Transactional Outbox Pattern & Pol
Explain why a distributed transaction is not available across services, and what a saga does instead.
Write a compensation for each step, and run them in reverse order.
Explain why compensations must be idempotent and retried.
Name what a saga gives up: isolation and a simple "all or nothing".
Before you start
Finish Lab 41 (Transactional Outbox) and Lab 42 (API Idempotency Keys) first. You should know why a retry can arrive twice. Docker Desktop and Python 3 are needed.