MySQL Forums
Forum List  »  InnoDB

Re: Is this normal?
Posted by: Björn Danielsson
Date: January 11, 2005 10:35AM

OK, I tried my deadlock example in mysql-4.1.8 now, and I still
get a deadlock but in a different place:

1.mysql> select * from T where C = 42 for update;

2.mysql> select * from T where C = 42 for update;
-- The above select doesn't block now.

1.mysql> insert into T set C = 42;
-- The above insert blocks.

2.mysql> insert into T set C = 42;
ERROR 1213: Deadlock found when trying to get lock; Try restarting transaction

Only a slight difference, but this time it seems more intuitive
to me since it gives the impression of an underlying "optimistic"
locking strategy.

However the behaviour is still "pessimistic" if the row already
exists (i.e. the second select then blocks and the first update

Would it be possible to have an optimistic/pessimistic setting
that could be configured? One could use the pessimistic mode
while hacking prototype code, and then switch to optimistic mode
in situations where efficiency is as important as atomicity...

Options: ReplyQuote

Written By
January 06, 2005 12:32PM
January 07, 2005 03:30PM
January 07, 2005 03:36PM
January 07, 2005 10:55PM
January 10, 2005 05:08PM
Re: Is this normal?
January 11, 2005 10:35AM
January 12, 2005 09:56AM
January 12, 2005 04:46PM
January 12, 2005 05:36PM

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.