Try
↑ ↓ move↵ openesc close

Interview prep / Sagas

Mid · Sagas · System design interview question

A saga has done three of five steps and step four fails. What happens next, and what if a compensation fails too?

Sketch your own answer first, then compare it with the one below.

A strong answer

The saga runs the compensations for steps three, two and one, in reverse order. When they finish, the saga ends as compensated.

A compensation that fails is retried. It must be safe to repeat, so give it an idempotency key. If it keeps failing, the saga cannot finish by itself. Park it, raise an alert, and let a person or a repair job decide. Compensations should be written so they cannot fail for business reasons, only for transient ones.

The orchestrator must write its progress durably before each step. After a crash, it reads where the saga stood and carries on.

Sources

Learn it by running it

The sagas and compensation lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms