Good day!
I’m using MySQL 5.0.41 and InnoDB table.
In the MySQL manuals not all absolutly clear about InnoDB table and row locks. Then I want to try it oneself.
About table and service:
- using INSERT DELAYED is bab idea;
- DELETE statement never applies for this table.
Using two sessions in the following succession I meet uncertainty about insert lock.
-------- process 1 --------
mysql> create table tbl(id int not null auto_increment, a int, b int, primary key (id),index ind_a(a)) engine=innodb;
mysql> insert tbl(a, b) values(1,1);
mysql> insert tbl(a, b) values(1,2);
mysql> insert tbl(a, b) values(2,3);
mysql> insert tbl(a, b) values(2,4);
mysql> _
All queries success.
-------- process 2 --------
mysql> set autocommit=0;
mysql> begin;
mysql> select * from tbl force index(ind_a) where a=1 for update;
(recordset output)
mysql> _
All queries success.
-------- process 1 --------
mysql> insert tbl(a, b) values(1,5);
At this time insert lock happens.
One simple question: why?
What ways I have around this lock?
THANKS!
P.S.
sorry, my English is in Alpha version.