Digital wallet

Func req

  1. Transfer money

NFR

When data does not fit one DB or has to be distributed in diff regions it may happen that we need two transactions.

One of the solutions is 2 phase transactions.

👎There are 2 locks in 2 diff DBs. If one DB is slow => all transactions are slow.

👎If wallet service fails => we do not know about transactions which were not yet finished. Wallet servie as coordinator should have internal DB with statuses of Prerape and commit phases of all transactions. It will help to find out problems if smth was not properly finished.

Alternative => Compensating transactions

Try -> confirm -> cancel

Database A tries to change a balance in transaction. Then DB B confirms in another transaction. If anything goes wrong DB A cancels in another transaction.

If anything goes wrong then:

Saga pattern

Saga coordinator will maintain a state in internal DB about all transactions start and end.

Last updated