MySQL Forums
Forum List  »  InnoDB

Row Level Locking Problems
Posted by: Harlan Noonkester
Date: April 20, 2007 12:47PM

My SQL 5.0.15, InnoDB

We have found cases where more than the selected row is being locked. A simple example is given below. When an order by is used in the first select statement it (apparently) places exclusive locks on rows in addition to the one selected. These additional row locks prevent the second statement from executing.

This behaviour is not consistent with row-level locking and I have not found any comprehensive explanation in the documentation (including Innodb-locks-set http://dev.mysql.com/doc/refman/5.0/en/innodb-locks-set.html). I would appreciate any help you can offer.

// Table to use in our test
CREATE TABLE `test`.`block` (
`id` int(10) unsigned NOT NULL auto_increment,
`shape` char(10) NOT NULL,
PRIMARY KEY (`id`),
KEY `BY_SHAPE` (`shape`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into block values (null, 'Triangle');
insert into block values (null, 'Square');
insert into block values (null, 'Circle');

// In one session perform the following.
begin;
select * from block where shape = 'square' order by id for update;

// In another session preform the following.
begin;
select * from block where shape = 'circle' order by id for update;

Options: ReplyQuote


Subject
Views
Written By
Posted
Row Level Locking Problems
5864
April 20, 2007 12:47PM
2496
September 22, 2008 12:42AM


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.