Fintech Lab
Lesson 36Distributed transactionsAdvanced
Sagas and compensating actions
When step 2 fails after step 1 committed, you can't rollback, you compensate.

A user wants to wire ₦50,000 to an external bank. The flow has two committed steps: (1) debit your user's wallet and mark the funds as 'wire in flight' (committed in your DB), (2) call your sponsor bank's API to initiate the actual wire (an external system you don't control). What happens when step 1 commits but step 2 fails? You can't ROLLBACK, the commit is final. You COMPENSATE: post a new entry that undoes step 1's effect. The audit trail shows the failure honestly: initiated, failed, compensated. This is the saga pattern, and it's what separates fintechs that survive partial outages from ones that ship corrupt state.

Fintech Lab is a free, interactive lab for fintech engineers. Real ledger, your own sandbox, engineering patterns from production. See all 85 lessons.

Search lessons

Type to find any of the 85 lessons. Press Enter to open.