Subject | Re: [firebird-support] Firebird.log |
---|---|
Author | Mauro Formigoni Junior |
Post date | 2005-09-01T18:27:24Z |
Henner Kollmann wrote:
User1:
starts transaction
update table1 set field2 = 'value' where id = 1;
(locked)
User2:
starts transaction
update table1 set field2 = 'value' where id = 500;
(locked)
User2:
update table1 set field2 = 'other value' where id = 1;
(wait the lock of User1)
User1:
Update table1 set field2 = 'other value' where id = 500;
-->DEADLOCK
The last update would wait for the lock of User2 because it's trying to
update a record wich is being updated (id=500), but the User2 is already
waiting for the record locked to User1 (id=1), in this case the database
chooses one of the transactions and kills it (I think the newest is
killed, but not sure).
The same situation can happen between 3 or more users in a circular
deadlock.
In the example the deadlock is in one table, it can happen (and occurs
more frequently) between 2 tables.
Mauro.
_______________________________________________________
Yahoo! Messenger com voz: PROMOÇÃO VOCÊ PODE LEVAR UMA VIAGEM NA CONVERSA. Participe! www.yahoo.com.br/messenger/promocao
> That's clear. But how can this happen on the firebird server? I think thisImagine the situation bellow in the exact order it is:
> should'nt...
>
> Henner
>
User1:
starts transaction
update table1 set field2 = 'value' where id = 1;
(locked)
User2:
starts transaction
update table1 set field2 = 'value' where id = 500;
(locked)
User2:
update table1 set field2 = 'other value' where id = 1;
(wait the lock of User1)
User1:
Update table1 set field2 = 'other value' where id = 500;
-->DEADLOCK
The last update would wait for the lock of User2 because it's trying to
update a record wich is being updated (id=500), but the User2 is already
waiting for the record locked to User1 (id=1), in this case the database
chooses one of the transactions and kills it (I think the newest is
killed, but not sure).
The same situation can happen between 3 or more users in a circular
deadlock.
In the example the deadlock is in one table, it can happen (and occurs
more frequently) between 2 tables.
Mauro.
_______________________________________________________
Yahoo! Messenger com voz: PROMOÇÃO VOCÊ PODE LEVAR UMA VIAGEM NA CONVERSA. Participe! www.yahoo.com.br/messenger/promocao