Can the MySQL repeatable read isolation level (RR level) avoid phantom reading

Check the transaction isolation level in MySQL client A (the default is RR level),
insert image description here
start the transaction on client A, and check the trax_learn table.
insert image description here
Open a new client B and add a new piece of data to the trax_learn table.
insert image description here
Check the trax_learn table in client A again and find that there are still only two records.
insert image description here
Commit the transaction on client A. commit, and check again.
insert image description here
It is found that the data inserted in client B is displayed, indicating that during the transaction execution of client A, the operation of client B on the table will not affect client A, avoiding phantom reading.
The main reason for this situation is that ordinary select statements are snapshot reads , and when transaction A starts, its snapshot data has been locked by the version. If transaction A is adjusted to the current read , a phantom read will occur.

Therefore, it is not accurate to say that the RR isolation level of InnoDB solves the problem of phantom reading or does not solve it. It should be said that it does not completely solve the problem of phantom reading.

Guess you like

Origin blog.csdn.net/weixin_45930241/article/details/123533556