MySQL5.7.11、tx_isolation は REPEATABLE-READ です。
このような表:
CREATE TABLE a (
id int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
insert into a values(1);
session1 で、次のように実行します。
begin;
select * from a where id=2 for update;
次に、session2 で次を実行します。
begin;
insert into a values(3);
session2 がブロックされており、GAP ロックのために session2 がブロックされていると思いますが、information_schema.innodb_lock では、最高の疑似レコードと RECORD ロックを示しています。
*************************** 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 は次のように説明しています。
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.
なぜ Record Lock であり、lock_data が supremum 疑似レコードなのですか?