Subject | Re: Deadlock question |
---|---|
Author | Adam |
Post date | 2006-04-10T04:52:19Z |
--- In firebird-support@yahoogroups.com, Robert martin <rob@...>
wrote:
lock conflict.
If you are using a NOWAIT transaction, you will receive an exception
immediately. If you are using a WAIT transaction, the second
transaction will 'freeze' to see what the first does. If the first
commits then the second receives an exception. If the first rolls
back, then the second will succeed in its update.
If you are maintaining a single counter for qty of an item, then you
effectively serialise it. There are better methods to maintain a
count which do not serialise.
Adam
wrote:
>record)?
> Hi
>
> If I run the following SQL from two applications / threads
> simultaneously should I get a deadlock (Where aPK is the same
>The behaviour depends on the isolation mode, but Yes you will get a
> UPDATE aTable SET Qty = Qty + :Qty WHERE aPK = :aPK;
lock conflict.
If you are using a NOWAIT transaction, you will receive an exception
immediately. If you are using a WAIT transaction, the second
transaction will 'freeze' to see what the first does. If the first
commits then the second receives an exception. If the first rolls
back, then the second will succeed in its update.
If you are maintaining a single counter for qty of an item, then you
effectively serialise it. There are better methods to maintain a
count which do not serialise.
Adam