Subject Re: Fwd: How to avoid deadlock ?
Author Dmitry Yemanov
14.01.2012 0:29, Vander Clock Stephane wrote:
>
> What i want to say :
>
> Table_A
> Field_A
> 12
>
> Transac 1 (isc_tpb_wait) :
> update Table_A Set Field_A = Field_A + 1;
>
> At the same time
>
> Transac 2 (isc_tpb_wait) :
> update Table_A Set Field_A = Field_A + 1;
>
> here we imagine a dead lock will appear !
> but we set isc_tpb_wait to say to wait
> that the lock dispear
>
> BUT the probleme is that at the begining
>
> Transac_1 Is the first to do the job (FieldA = 12)
> Transac_2 wait (FieldA = 12)
> Transac 1 finish the job (FieldA = 13)
> Transac_2 ok i can do the job ... ooh no i can't because fieldA <> what
> it was at the begining 12 :(

As far as I understand, your problem can be worked around in two
different ways in Firebird:

a) by using read-committed no-record-version isolation mode
b) by locking the records explicitly (SELECT WITH LOCK) before updating


Dmitry