I have a rather basic question on transactions.
Assume a table
Account with a column amount. Now we have the following code:
BEGIN $amount = SELECT amount FROM ACCOUNT WHERE id = 123; $amount = $amount - 100; UPDATE ACCOUNT SET amount = $amount WHERE id = 123; COMMIT
Now if this snippet runs concurrently by 2 transactions, T1 and T2 what will happen?
I know that in MySQL by default the isolation level is
So let's say that amount initially is 500.
So when the 2 transactions finish will the final amount be 300 or 100?
I mean when they start both read from table which I guess is a shared lock.
When one updates the table it gets an exclusive lock right? So what happens to the other transaction? Will it proceed with the amount it "view" when it started i.e. 500?