strange dead lock.
Posted in 2003
Topics: Transactions, Locking & Isolation
I have a program, which has a dead lock problem. but
I don't know the reason.
I set transaction leve to TRANSACTION_SERIALIZABLE(repeatable read).
I created index on id. I use row lock.
first I do
select id from test where id = k(int value) for updatethen I do some other things on another table
last I do
delete from test where id = k.
this code will be executed in different process concurrently.
After investigation, I found that two threads which have dead lock with each
other,
both were executing the last step(delete from ...), but k value is different.
Can dead lock happen when two threads execute same sql statement?
I don't understand why there has a dead lock, Can anybody explain it?
Thanks in advance.
Row or
page level locking? Also, repeatable read locks all rows that are
examined, not just the rows that satisfy the query. So if you aren't doing
an indexed read to find that row, it's quite possible that you are locking
more rows than you think you are.
--
Bye now,
Obnoxio
"C'est pas parce qu'on n'a rien à dire qu'il faut fermer sa gueule"
- Coluche
"Necrophilia means never having to say ... well, anything!"
- Captain Pedantic
"Ogni uomo mi guarda come se fossi una testa di cazzo"
- Marco
From: "JACK" <jackleeok@yahoo.com>
>
>I have a program, which has a dead lock problem. but I don't know the
>reason.
>I set transaction leve to TRANSACTION_SERIALIZABLE(repeatable read).
>I created index on id. I use row lock.
>
>first I do
> select id from test where id = k(int value) for update>then I do some other things on another table
>last I do
> delete from test where id = k.>
>this code will be executed in different process concurrently.
>After investigation, I found that two threads which have dead lock with
>each other,
>both were executing the last step(delete from ...), but k value is
>different.
>Can dead lock happen when two threads execute same sql statement?
>
>I don't understand why there has a dead lock, Can anybody explain it?
>
>Thanks in advance.
>
_________________________________________________________________
Sign-up for a FREE BT Broadband connection today!
http://www.msn.co.uk/specials/btbroadband