The current transaction can read data written by another uncommitted transaction, which is also called dirty read.
For example, A wants to add some amount to his account and transfer it to B. Assume both the transactions happen at the same time; the flow will be like this.
A initially has $400 and wants to transfer $500 to B after adding $500 to his account.
# Transaction 1 (adding amount) | # Transaction 2 (transferring amount) |
BEGIN; |
BEGIN; |
UPDATE account SET balance=balance+500 WHERE account_number='A'; |
-- |
-- |
SELECT balance INTO @a.bal FROM account WHERE account_number='A'; # A sees 900 here |
ROLLBACK; # Assume due to some reason the transaction got rolled back |
-- |
-- |
# A transfers 900 to B since A has ... |