MySQL5.7.11, tx_isolation is REPEATABLE-READ;
Table like this:
CREATE TABLE a (
id int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
insert into a values(1);
in session1, execute like this:
begin;
select * from a where id=2 for update;
then in session2, execute:
begin;
insert into a values(3);
session2 is blocked, and I think session2 is blocked because the GAP lock, but in information_schema.innodb_lock, it shows supremum pseudo-record and RECORD Lock;
*************************** 1. row ***************************
lock_id: 234076:115:3:1
lock_trx_id: 234076
lock_mode: X
lock_type: RECORD
lock_table: `test`.`a`
lock_index: PRIMARY
lock_space: 115
lock_page: 3
lock_rec: 1
lock_data: supremum pseudo-record
*************************** 2. row ***************************
lock_id: 234075:115:3:1
lock_trx_id: 234075
lock_mode: X
lock_type: RECORD
lock_table: `test`.`a`
lock_index: PRIMARY
lock_space: 115
lock_page: 3
lock_rec: 1
lock_data: supremum pseudo-record
2 rows in set (0.00 sec)
MySQL_Doc describes it as follow:
For the last interval, the next-key lock locks the gap above the largest value in the index and the
“supremum” pseudo-record having a value higher than any value actually in the index. The supremum
is not a real index record, so, in effect, this next-key lock locks only the gap following the largest index
value.
why is the Record Lock and the lock_data is supremum pseudo-record?