Saga Design Pattern
What is a saga?
A saga is a common microservice design pattern for handling failure in a transaction that spans multiple microservices.
When a failure occurs in any of the services that are part of the overall transaction, compensating action has to be taken.
doAction();
doCompensatingAction();
The classic use case is that of an order, payment, inventory update and delivery. These steps involve a number of microservices:
If something goes wrong at any stage, compensating actions are taken. These can be triggered by choreography (a decentralized event driven approach) or by orchestration (a centralized process where an orchestrator is responsible for enacting the compensating actions).
Either way, one of the main issues we face when implementing the Saga design pattern is that of dirty reads - inconsistent state during a compensating action.