MySQL repeatable read and lost update/phantom reads

后端 未结 1 993
迷失自我
迷失自我 2020-12-16 03:30

I tried this with MySQL Server 5.5:

1) ensured that transaction isolation level is repeatable_read

2) started shell-1, started a transaction in it, then read

1条回答
  •  天涯浪人
    2020-12-16 04:25

    MySQL does not conform to Repeatable Read really. You can force it to do by using isolation level serializable or by putting an FOR UPDATE after your selects (look at the example below). Then the desired behaviour will be achieved. Regarding phantom reads, MySQL is actually stricter than necessary...

    SELECT value FROM table WHERE id = 7 FOR UPDATE;
    

    0 讨论(0)
提交回复
热议问题