Let's suppose there are two banks, Bank A and Bank B. A transaction needs to happen that transfers money from an account in Bank A to an account in Bank B. Bank A and Bank B have separate banking systems which makes this transaction a distributed one. From what I understand following is what happens, I refer the system of bank A as A and the system of bank B as B,
A initiates the transaction
A sends a message including the amount to B
A waits for a response from B
B adds the amount to the account send a response to A
A receives the response and deduct the amount from account
Transaction completes.
A can complete the transaction if it received the response since it is a guarantee that B has done the addition, but if A doesn't receive a response, it cannot guarantee that B has done the addition, so it cannot complete the transaction. In that case, what if B has done the addition successfully but the response message was lost in transit. Now A hasn't done the deduction while B has done the addition which is an inconsistent state. How do we solve that problem?