ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU-(2020-2021)-1 > student homework > 2018529627017_ChipusileJohnSikasote >
Homework 5 Version 0
👤 Author: by chipusilesgmailcom 2020-11-16 07:05:20
From a technical standpoint, a payment transaction is some unit of work performed in distributed systems. Every database transaction has ACID properties – they are atomic, consistent, isolated and durable. But when it comes to payments, transactional consistency means that a transaction can go through without any issues (even if the user messed up something).

Here’s a quick example to illustrate this point: You are PSP (payment service provider) such as PayPal. Some user wants to send $25 to an eBay seller. So, when the person clicks that “pay” button, several things happen behind the hood:

  • The user transaction gets registered in the system.

  • The system proxies this transaction request to acquiring bank.

  • And then it patiently waits for notification from the bank that the transaction went through alright.


But then things suddenly go awry. Instead of one notification, we got two:

  • One from the bank stating that the transaction was processed.

  • Another one from our system saying that the user clicked the cancel button during processing or hit page refresh (or otherwise interfered with the process).


Now there’s a problem: we have a transaction that’s, at the same time, processed and cancelled. Here you go – that’s a prime example of payment transaction inconsistency.

But now we need to figure out which one is correct. And that’s somewhat challenging as those two actions were processed in parallel.

When we don’t have a guarantee of consistency in our system, we can have acid in databases but still not have strong consistency guarantee in distributed systems. As a result, we have a three-way inconsistency between our system, customer and acquiring bank.

The technical fix: transaction locking

To solve this conundrum, we can do one great thing: apply a lock on transaction entity when we perform any operation with it. Locking gives us the guarantee that only one action can be processed at any given time.

If that’s the case, here’s how the previous scenario would unroll: after the user hits cancel, we place a lock on transaction to cancel it. At the same time, the bank gets in line to process that transaction. After it acquired lock to proceed, our system already knows that the transaction is cancelled. So, we send that info to the bank and it rolls back the transaction.

Everyone’s happy.

Now let’s move on to the technical part of this post: a quick case study showing exactly how distributed locks can be applied towards payment transactions to ensure consistency.

 

Please login to reply. Login

Reversion History

Loading...
No reversions found.