Exercise 2: Update Anomaly
Consider the following transaction (expressed in pseudo-code):
transfer(src id, dest id, amount int)
{
select balance from Accounts where id = src;
if (balance >= amount) {
update Accounts set balance = balance-amount
where id = src;
update Accounts set balance = balance+amount
where id = dest;
} }
|
If two transfers occur on this account simultaneously,
give a schedule that illustrates the "dirty read" phenomenon.
|