I found a difference of snapshot between mysql5.7.34 and mysql8.0.25 and I want to know why.
Transaction Isolation:REPEATABLE READS
this is the table I used
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`yn` int(11) DEFAULT NULL,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4
Initial data
id | yn | name |
---|---|---|
1 | 1 | w |
2 | 0 | w |
3 | 0 | w |
Number | Transaction1 | Transaction2 |
---|---|---|
1 | begin | |
2 | select * from test | |
3 | begin | |
4 | update test set yn=0 where id=1 | |
5 | commit | |
6 | select * from test | |
7 | update test set yn=0 where yn=1 | |
8 | select * from test | |
9 | update test set yn=0 | |
10 | select * from test | |
11 | commit |
In step 10, if I use mysql8, the output is
id | yn | name |
---|---|---|
1 | 1 | w |
2 | 0 | w |
3 | 0 | w |
But when I use mysql5.7, the output of step 10 is
id | yn | name |
---|---|---|
1 | 0 | w |
2 | 0 | w |
3 | 0 | w |
I can understand the behavior of mysql5.7. The operation of step 9 update the snapshot of data whose id is 1 if I use mysql5.7. I want to know why mysql8 does not update snapshot like mysql5.7? what is the defference between mysql5 and mysql8 which lead to the different behavior?
Any input will be appreciated.
Thanks