Try
↑ ↓ move↵ openesc close

Interview prep / Sagas

Mid · Sagas · System design interview question

What isolation anomalies can a saga show, and how do you reduce them?

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

A strong answer

Because each step commits at once, others see the middle. A reader can see a charge that a later failure refunds, a dirty read in effect. Two sagas can touch the same record, and one can overwrite what the other relied on, a lost update. A saga can also read one value twice and get two answers.

Countermeasures include a semantic lock, which is a pending flag that other code must respect. Commutative updates, so order does not matter. A pessimistic order of steps, so the hardest to undo comes last. Re-reading a value before a step relies on it, and versioning records.

Each one pushes work onto the application. Say that the saga's isolation is something you build, not something you get.

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