Friday, 20 October 2006

Dead lock encountered today

I have met with a dead lock today in my web service application. It's very hard to find initially because each stored procedure is running fine individually but when tie them together a dead lock occurs.

What happens is I have several stored procedures having insert/update, others only have read access. I put all insert/update stored procedures inside a transaction using ado.net transaction, while decide to leave read only stored procedures outside of transaction. It worked fine until I put a insert statement in one of my read stored procedure, which insert into a same table which is under transaction control. Then dead lock occurs here because the table is locked.

I tried hard to figure out this bug and decided to put everything inside the transaction. Then the bug was fixed.

No comments: