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
succeeds).

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


Subject
Views
Written By
Posted
4415
January 06, 2005 12:32PM
3016
January 07, 2005 03:30PM
2898
January 07, 2005 03:36PM
3332
January 07, 2005 10:55PM
2980
January 10, 2005 05:08PM
Re: Is this normal?
3049
January 11, 2005 10:35AM
3277
January 12, 2005 09:56AM
2963
January 12, 2005 04:46PM
3634
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.