|
Posted by Marcus on 09/09/05 02:20
Hello all,
I am trying to figure out when it is appropriate to use shared and
exclusive locks with InnoDB. Using shared locks (lock in share mode), I
can easily create a scenario with 2 clients that deadlocks - start 2
transactions, open 2 shared locks, and both try to insert a new row
before either commits.
Using exclusive locks (for update) I cannot come up with a scenario that
results in a deadlock, since the very nature of the exclusive lock means
no other queries should be able to access the row(s) in question until I
commit.
If this is the case, my question then is this: why would I ever use a
shared lock if doing so can result in deadlocks? There must be a reason
because we have them, and going through tutorials I can see HOW they are
used, but I am not sure what advantage they would have over exclusive
locks. It seems to me that exclusive locks are "safer", but I know I
must be overlooking something.
Thank you all in advance for your help.
Marcus
Navigation:
[Reply to this message]
|