MySQL version:5.7.29 Homebrew
ENGINE=InnoDB
REPEATABLE READ
MVCC snapshot question:
the table:
CREATE TABLE `r` (
`id` int NOT NULL primary key auto_increment,
`v` int not null
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into r values (1,1);
the steps:
-----transaction A -------------| transaction B
--------------------------------|---------------------------
---------begin;-----------------| --
1, select * from r;-------------| --
--------------------------------| begin;
--------------------------------| update r set v=v+1 where id = 1;
--------------------------------| commit;
2, select * from r;-------------| --
update r set v=v+1 where id = 1;| --
3, select * from r;-------------| --
----------commit;---------------| --
step 1 and 2 v = 1, but why step 3 v = 3, cuz MVCC I think that v should be 2. please help me out.