示例:
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
START TRANSACTION;
SELECT * FROM t1; // to "create shapshot". For simplicity t1 contains 1 row 1 column which contains value 1.
// another transaction updates this row and change 1 to 2 and commits.
SELECT * FROM t1; // we see no changes. As expected in repeatable read.
SELECT * FROM t1 FOR UPDATE; // i see change row. Why?
我找不到解释这种行为的原因。为什么读锁会忽略隔离级别?
FOR UPDATE
后添加SELECT * FROM t1;
仍然返回值 1。我可以理解为什么会这样,但有点令人惊讶。 - ysth