Durable network communication dilemma

47 Views Asked by At

Lets imagine that we have a bank and an ATM. They communicate over network, which could fail. Is it possible to create a scenario, where communication between them is 100% durable. In this case it means, that:

client withdrawn physical amount of money
<=>
account balance updated accordingly

Let's check couple of scenarios:

  • ATM sends a requests, bank sends a confirmation. Confirmation get lost, bank updated account but client haven't got the money.
  • (if bank awaits confirmation from ATM to update balance) ATM sends a requests, bank sends a confirmation, ATM sends ack for reception. Ack got lost. ATM issued money, but bank never updated an account.

So I never could create a solution, where failing network would not prevent money from getting lost on either side.

Please, advise.

1

There are 1 best solutions below

0
On

Actually, if I am not misunderstanding your question, you're probably talking about Long Wait algorithm.

In your first step---I'd suggest you to wait until the confirmation is not received(acknowledged) by the ATM or vice-versa. This is the only viable solution in this case. In this case,you set up a minimum fixed time-bound after which if the acknowledgement isn't received, you again request the same from the bank at each regular interval of n time-unit(the minimum time unit for checking acknowledgement from bank by the ATM). If it repeatedly fails, this means there is something wrong with the code OR concept.

Also, do utilise the concept of Redo Log Buffer as these are the best option to store and update the bank balances !!! Don't just keep only one copy,but two or three copies of the account information and make changes in temporary copy and only update the final account info in redo log once the acknowledgement from the ATM is received to the bank or the vice-versa! Mind receiving the acknowledgement before updating values in redo log!