步骤
|
事务1
|
事务2
|
事务3
|
1
|
begin;
|
||
2
|
begin;
|
||
3
|
insert into test(score) select 101;
此时事务ID为101
|
||
4
|
insert into test(score) select 102;
此时事务ID为102
|
||
5
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 1 | 101 |
+----+-------+
此时就会建立read view:
up_limit_id = 101
low_limit_id = 103
trx_ids为(101,102)
而101自身可见,102在活跃事务列表中不可见
|
||
6
|
insert into test(score) select 103;
此时事务ID为103
|
||
7
|
insert into test(score) select 104;
此时事务ID为104
|
||
8
|
nsert into test(score) select 105;
此时事务ID为105
|
||
9
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 3 | 103 |
| 4 | 104 |
| 5 | 105 |
+----+-------+
此时的up_limit_id=101,
low_limit_id=106,
trx_ids为(101, 102),
而101和102在trx_ds列表中不可见
|
||
10
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 2 | 102 |
| 3 | 103 |
| 4 | 104 |
| 5 | 105 |
+----+-------+
此时就会建立read view:
up_limit_id=101,
low_limit_id=106,
trx_ids为(101, 102),
102自身可见,101在活跃事务列表中不可见
而10三、10四、105不在trx_ids列表中全部可见
|
||
11
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 1 | 101 |
| 3 | 103 |
| 4 | 104 |
| 5 | 105 |
+----+-------+
因为事务内read view不变
(与RC的区别就在这),
此时的up_limit_id=101,low_limit_id=103,
trx_ids为(101, 102),
101自身可见,102在活跃事务列表中不可见
而>=103的都不可见
|