Another example of what could go wrong, is, is here.

This is known as the inconsistent retrieval problem.

Here again, I have two transactions.

These two transactions are different, and

I'm showing an interleaving order for them.

Let's see, each of these transactions.

[NOISE] So Transaction T1, the one of the left,

first gets seats from a flight ABC123.

Then gets seats from a different flight ABC789.

Stores them in variables x and y respectively.

Again x and y are local variables at T1.

[NOISE] Then it transfers 5 seats from ABC123 to ABC789.

It does so by simple writing x minus 5 to ABC123, and

writing y plus 5 into ABC789, and then it commits.

In the meantime, concurrently, Transaction T2 is trying to add up, or

sum up the total number of flights available on, sorry,

seats available on these two flights.

So it gets the number of seats from ABC123, stores it into x,

a local variable at T2.

[NOISE] Similarly, it ABC789, and stores it into y, a local variable at T2.

It adds both of them, and prints out the result and value.

So let's see what could go wrong.

[NOISE] So at the server is saying initially,

the number of seats available on ABC123 is 10, and ABC789 is 15.

'Kay, so, really Transaction T2 should output a total value of 10 plus 15 or

25 seats at the end of this.

That's the value that we would expect, right?

[NOISE] Let's see what really happens, so,

first, when transaction T1 executes its first three operations, it gets the values

of 10 and 15, then it writes the value of 10 minus 5, or, 5 into ABC123.

At this point, this on the server-side ABC123 is 5.

Now Transaction T2 executes its getSeats ABC123.

And it gets, x equals 5 because that's what is the value on the server-side,

it gets y equals 15, that's unchanged from four.

And when it adds these two, it prints out a total value of 20, 'kay?

So, what really got lost in translation here?

Was this 5 which was in transit in a sense, in Transaction T1.

Where Transaction T2 read the partial results or

the intermediate results or the dirty update, this write done by T1,

was an intermediate result that was read by T2.

And that is what read to the wrong result of 20,

where the result should really have in 25.

So this is what is known as an inconsistent retrieval problem, and

this also arises because we didn't do anything special here,

to guarantee asset properties.

In the next lecture we'll see,

mechanisms that prevent transactions from affecting each other, and

that try to guarantee asset properties when you have, concurrent transactions and

many concurrent transactions, executing with one server

[MUSIC]