Subject | Re: [firebird-support] Firebird.log |
---|---|
Author | Ann W. Harrison |
Post date | 2005-09-02T14:40:04Z |
Henner Kollmann wrote:
error message. The victim should detect the error and rollback its
transaction, which will break the deadlock and allow processing to continue.
than 10 seconds.
transaction starts, it takes out an exclusive lock on its transaction id.
that contains the transaction id of user1.
that contains the transaction id of user2.
Firebird on its behalf) encounters the record version created by User1.
Since User1 is active, Firebird tells User2 that it can not overwrite
an uncommitted change. Depending on the transaction type User2 either
gets an error immediately (no wait) or requests a lock on the
transaction id of User1.
Firebird on its behalf) encounters the record version created by User2.
Since User21 is active, Firebird tells User1 that it can not overwrite
an uncommitted change. Depending on the transaction type User1 either
gets an error immediately (no wait) or requests a lock on the
transaction id of User2.
At this point, User1 is waiting for a shared lock on the transaction id
of User2 and User2 is waiting for a shared lock on the transaction id of
User1. As soon as one or the other has waited 10 seconds, Firebird
scans the lock table, looking for cycles in the wait-for graph. (That's
pigeon gook-speak for two transactions waiting for each other.)
Ann
> That's interesting. I firebird really killing the transaction or will itFirebird discovers deadlocks, picks a victim arbitrarily and sends an
> wait infinite until the client will kill the connection?
error message. The victim should detect the error and rollback its
transaction, which will break the deadlock and allow processing to continue.
>Deadlock scans are performed when a lock request has waited for more
> Is it possible to wait only a few seconds and catch an error then?
than 10 seconds.
> Is it possible to log which table is deadlocked?No.
>Here's how the situation actually happens in Firebird. When a
transaction starts, it takes out an exclusive lock on its transaction id.
>>Imagine the situation bellow in the exact order it is:The record is NOT locked, but a new version of the record is written
>>
>>User1:
>>starts transaction
>>update table1 set field2 = 'value' where id = 1;
>>(locked)
that contains the transaction id of user1.
>>The record is NOT locked, but a new version of the record is written
>>User2:
>>starts transaction
>>update table1 set field2 = 'value' where id = 500;
>>(locked)
that contains the transaction id of user2.
>>When User2 tries to write a new version of the record, it (actually
>>User2:
>>update table1 set field2 = 'other value' where id = 1; (wait
>>the lock of User1)
Firebird on its behalf) encounters the record version created by User1.
Since User1 is active, Firebird tells User2 that it can not overwrite
an uncommitted change. Depending on the transaction type User2 either
gets an error immediately (no wait) or requests a lock on the
transaction id of User1.
>>When User1 tries to write a new version of the record, it (actually
>>User1:
>>Update table1 set field2 = 'other value' where id = 500;
Firebird on its behalf) encounters the record version created by User2.
Since User21 is active, Firebird tells User1 that it can not overwrite
an uncommitted change. Depending on the transaction type User1 either
gets an error immediately (no wait) or requests a lock on the
transaction id of User2.
At this point, User1 is waiting for a shared lock on the transaction id
of User2 and User2 is waiting for a shared lock on the transaction id of
User1. As soon as one or the other has waited 10 seconds, Firebird
scans the lock table, looking for cycles in the wait-for graph. (That's
pigeon gook-speak for two transactions waiting for each other.)
>>-->DEADLOCKRight. One of the two waiting transactions will get an error.
>>Regards,
Ann