MySQL Forums
Forum List  »  InnoDB

confused by the innodb gap lock
Posted by: Luke Lu
Date: March 06, 2014 01:27AM

i have a table like
create table t
(
a int primary key,
b int
) engine=innodb;

create index inx_t_b on t(b);
insert into t select 1,10;
insert into t select 2,10;
insert into t select 3,20;
insert into t select 4,20;
insert into t select 5,30;
insert into t select 6,30;
commit;
=============================
then in session A: isolation level: repeatable read
select * from t where b<=10 for update;
according to the innodb gap lock,this will lock the gap (-∞,10] and (10,20] on index inx_t_b
and lock the record 1 and 2 on primary key

in session B:isolation level: repeatable read
insert into t values (100,100)

It's observed the SQL statement in session B is blocked and finnaly it will be timeout and failed,because
it can't obtain the lock

So i am confused why the SQL in session A block SQL in session B?
what's the exact lock range for SQL in session A?

will some one help me out

the MySQL version is 5.6

Options: ReplyQuote


Subject
Views
Written By
Posted
confused by the innodb gap lock
1259
March 06, 2014 01:27AM
807
March 08, 2014 12:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.