Distributed Systems
Sagas: multiple-choice review
Six questions that cut across the whole unit. Each mirrors a design call you make when one transaction cannot span the work — not a definition to recite, but a tradeoff to weigh when partial failure is the normal case.
Confirm you can connect why 2PC fails across services, why a compensation is not a rollback, when choreography beats orchestration, and which anomalies fall out of losing isolation — the synthesis the lesson built toward.
A checkout path crosses six services, one of them a third-party payment gateway. Why is wrapping them in one two-phase commit the wrong move?
Step T2 charges the card; step T3 fails, so the saga runs C2. What does C2 actually do, and why does the distinction matter?
A trip saga does T1 book flight, T2 book hotel, T3 rent car, then charge the card, then email a confirmation. Why does a senior order it this way?
A 6-step order flow spans 5 services with retries, timeouts, and a manual-approval step that can wait days. Choreography or orchestration?
Saga B reads an order that saga A has committed but will later compensate away, and acts on it. Which anomaly is this, and why is it even possible?
Two sagas concurrently adjust the same account balance and one overwrites the other's change. Which countermeasure removes this lost update most directly?
The through-line: a single ACID transaction cannot span services, and 2PC’s cure — cross-service locks plus a blocking coordinator — is worse than the disease. A saga gives up the global transaction for local commits plus hand-written compensations, which are new forward actions, not rollbacks, so you order irreversible steps last. You wire steps with choreography (decentralized but scattered) or orchestration (one durable place to read and resume), and you pay for losing isolation with application-level defences — semantic locks, commutative updates, and version checks — against dirty reads and lost updates.