Learning pathsPricingChecking sign-in…
GUIDED PRACTICE

Saga and Reconciliation

A saga coordinates business steps across independent transactional boundaries; compensation is a new business action, not a database rollback.

Saga and Reconciliation

A saga coordinates business steps across independent transactional boundaries; compensation is a new business action, not a database rollback. An orchestrator or choreography tracks durable workflow state. Each forward step has timeout, idempotency key and outcome. A compensating action attempts to restore a business invariant but can fail or be impossible. Reconciliation compares authoritative records and provider outcomes.

Mechanism and worked example

A travel booking reserves a seat, authorizes payment, confirms ticket and sends notification. If confirmation fails after authorization, void or refund using the original payment identity. If provider outcome is unknown, query it before issuing another authorization.

StateMeaningSafe action
PendingIntent durableCall with stable identity
SucceededProvider effect confirmedAdvance workflow
UnknownTimeout or lost responseQuery provider
Compensation pendingForward effect confirmed; later step failedRetry or escalate
ReconciledRecords and provider agreeClose workflow

Failure modes and operations

A timeout does not prove the remote step failed. Compensation can be duplicated or rejected. A workflow may crash after external effect but before recording completion. Retrying a non-idempotent step can charge twice. Some states need manual intervention.

Trade-offs and design boundary

Orchestration centralizes state and visibility but adds a workflow dependency. Choreography reduces central coordination but makes global diagnosis harder. Sagas provide eventual business recovery, not atomic isolation across services.

Interview transfer exercise

Payment authorization times out after request submission. Persist intent and stable identity, query provider outcome, then compensate only after confirming the forward effect occurred.

Diagram: Persist step and idempotency key; Execute external action; Record confirmed or unknown outcome; Compensate or reconcile before closing
Mechanism and decision flow for Saga and Reconciliation.
Read the diagram

Persist step and idempotency key → Execute external action → Record confirmed or unknown outcome → Compensate or reconcile before closing

Open original
Saga and Reconciliation
Diagram: Persist step and idempotency key; Execute external action; Record confirmed or unknown outcome; Compensate or reconcile before closing

Mechanism and decision flow for Saga and Reconciliation.

18:00Self-guided practice timer
The timer resets when you leave this page. Save your design separately.
Your challenge

Payment authorization times out after request submission. Persist intent and stable identity, query provider outcome, then compensate only after confirming the forward effect occurred.

Your design draft

Clarify assumptions, explain your approach, and test the difficult cases. Save your draft, then compare it with the study notes.

Read study notes

Self-review checklist

Self-guided practice. Automated AI feedback and code execution are not connected.