InnoDB & Isolation Levels - Aren't repeatable reads a bad thing?

80 views Asked by At

I was reading about InnoDB's isolation levels and it makes sense for the most part, but what I don't get is why are unrepeatable reads a bad thing? Shouldn't it be the other way around?

For examples:

So say we had a stock column for selling products and each time someone bought an item we would take 1 item from the column, with Repeatable read or serializable isolation levels wouldn't this corrupt the data integrity?

For example:

TX A: start transaction;
TX B: set session transaction isolation level repeatable read;
TX B: start transaction;
TX A: select stock from products;               -- val = 8
TX B: select stock from products;               -- val = 8
TX A: update products set stock = stock - 1;    -- val = 7
TX B: select stock from products;               -- val = 8
TX A: commit
TX B: select stock from products;               -- val = 8, incorrect!
TX B: commit;
TX B: select stock from products;               -- val = 7

Unless it uses the CORRECT value when running an update?

0

There are 0 answers